### Question:
GenericItemSourcePool implements ItemSourcePool<T> { @Override public final boolean remove() { try { ItemSource<T> pooled = removeInternal(MAX_RESIZE_INTERNAL_STACK_DEPTH); pooledObjectOps.purge(pooled); totalPoolSize.getAndDecrement(); } catch (PoolResourceException e) { return false; } return true; } GenericItemSourcePool(String poolName,
                                 PooledObjectOps<T> pooledObjectOps,
                                 ResizePolicy resizePolicy,
                                 long resizeTimeout,
                                 boolean monitored,
                                 long monitorTaskInterval,
                                 int initialPoolSize); @Override final void incrementPoolSize(int delta); @Override final void incrementPoolSize(); @Override final ItemSource<T> getPooled(); @Override final boolean remove(); @Override final String getName(); @Override final int getInitialSize(); @Override final int getTotalSize(); @Override final int getAvailableSize(); @Override // TODO: add shutdown(timeout) void shutdown(); @Override void start(); @Override void stop(); @Override boolean isStarted(); @Override boolean isStopped(); static final String THREAD_NAME_FORMAT; }### Answer:
@Test public void removeReturnFalseInsteadOfThrowingAfterUnderlyingPoolResourceException () { ResizePolicy resizePolicy = mock(ResizePolicy.class); when(resizePolicy.increase(any())).then((Answer<Boolean>) invocationOnMock -> { throw new PoolResourceException("test"); }); ByteBufPooledObjectOps pooledObjectOps = new ByteBufPooledObjectOps( byteBufAllocator, DEFAULT_TEST_ITEM_SIZE_IN_BYTES) { }; GenericItemSourcePool<ByteBuf> pool = spy(new GenericItemSourcePool<>( DEFAULT_TEST_ITEM_POOL_NAME, pooledObjectOps, resizePolicy, 0, false, DEFAULT_TEST_MONITOR_TASK_INTERVAL, 0 )); boolean resized = pool.remove(); assertFalse(resized); }