### Question:
MarshlandPool implements Pool<T> { @SuppressWarnings( "unchecked" ) @Override public T acquire() { LocalSlot<T> localSlot = puddle.get(); T obj = localSlot.localSlotObject; if ( obj != null ) { localSlot.set( null ); return obj; } LocalSlotReference<T> slotReference = (LocalSlotReference<T>) objectsFromDeadThreads.poll(); if ( slotReference != null && slotReference.localSlotReferenceObject != null ) { slotReferences.remove( slotReference ); return slotReference.localSlotReferenceObject; } return delegate.acquire(); } MarshlandPool( Pool<T> delegatePool ); @SuppressWarnings( "unchecked" ) @Override T acquire(); @Override void release( T obj ); @SuppressWarnings( "unchecked" ) @Override void close();  }### Answer:
@Test void shouldNotLooseObjectsWhenThreadsDie() throws Exception { Pool<Object> delegatePool = mock( Pool.class ); when( delegatePool.acquire() ).thenReturn( 1337, -1 ); final MarshlandPool<Object> pool = new MarshlandPool<>( delegatePool ); claimAndReleaseInSeparateThread( pool ); verify( delegatePool ).acquire(); verifyNoMoreInteractions( delegatePool ); assertPoolEventuallyReturns( pool, 1337 ); }