/**
 * Verify that an object that gets flagged as abandoned and is subsequently returned
 * is destroyed instead of being returned to the pool (and possibly later destroyed
 * inappropriately).
 */
Verify that an object that gets flagged as abandoned and is subsequently returned
is destroyed instead of being returned to the pool (and possibly later destroyed
inappropriately).
/ ** * Verify that an object that gets flagged as abandoned and is subsequently returned * is destroyed instead of being returned to the pool ( and possibly later destroyed * inappropriately ) . * /
func (suit *PoolAbandonedTestSuite) TestAbandonedReturn() {
	suit.pool.AbandonedConfig.RemoveAbandonedOnBorrow = true
	suit.pool.AbandonedConfig.RemoveAbandonedOnMaintenance = false
	suit.pool.AbandonedConfig.RemoveAbandonedTimeout = 1
	suit.factory.destroyLatency = 200
	n := 10
	suit.pool.Config.MaxTotal = n
	suit.pool.Config.BlockWhenExhausted = false
	var obj *AbandonedTestObject
	for i := 0; i < n-2; i++ {
		obj = suit.NoErrorWithResult(suit.pool.BorrowObject()).(*AbandonedTestObject)
	}
	if obj == nil {
		suit.Fail("Unable to borrow object from pool")
	}
	wait := new(sync.WaitGroup)
	wait.Add(1)
	deadMansHash := obj.hashCode()
	if debugTest {
		fmt.Println("deadMansHash:", deadMansHash)
	}
	concurrentReturner(suit.pool, obj, wait)
	sleep(2000) 
	wait.Done() 
	obj2 := suit.NoErrorWithResult(suit.pool.BorrowObject()).(*AbandonedTestObject)
	suit.True(obj2.hashCode() != deadMansHash)
	suit.Equal(0, suit.pool.GetNumIdle())
	suit.Equal(1, suit.pool.GetNumActive())
}
func ( suit * PoolAbandonedTestSuite ) TestAbandonedReturn ( ) { suit . pool . AbandonedConfig . RemoveAbandonedOnBorrow = true suit . pool . AbandonedConfig . RemoveAbandonedOnMaintenance = false suit . pool . AbandonedConfig . RemoveAbandonedTimeout = 1 suit . factory . destroyLatency = 200 n := 10 suit . pool . Config . MaxTotal = n suit . pool . Config . BlockWhenExhausted = false var obj * AbandonedTestObject for i := 0 ; i < n - 2 ; i ++ { obj = suit . NoErrorWithResult ( suit . pool . BorrowObject ( ) ) . ( * AbandonedTestObject ) } if obj == nil { suit . Fail ( " " ) } wait := new ( sync . WaitGroup ) wait . Add ( 1 ) deadMansHash := obj . hashCode ( ) if debugTest { fmt . Println ( " " , deadMansHash ) } concurrentReturner ( suit . pool , obj , wait ) sleep ( 2000 ) wait . Done ( ) obj2 := suit . NoErrorWithResult ( suit . pool . BorrowObject ( ) ) . ( * AbandonedTestObject ) suit . True ( obj2 . hashCode ( ) != deadMansHash ) suit . Equal ( 0 , suit . pool . GetNumIdle ( ) ) suit . Equal ( 1 , suit . pool . GetNumActive ( ) ) }
Verify that an object that gets flagged as abandoned and is subsequently returned
is destroyed instead of being returned to the pool (and possibly later destroyed
inappropriately).
Verify that an object that gets flagged as abandoned and is subsequently returned is destroyed instead of being returned to the pool ( and possibly later destroyed inappropriately ) .
// abandon checked out instances // Now start a race - returner waits until borrowObject has kicked // off removeAbandoned and then returns an instance that borrowObject // will deem abandoned.  Make sure it is not returned to the borrower. // short delay, then return instance