Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POOL-418] Do not retrieve from the blocking queue when the wait time is exhausted, and modify the corresponding test cases. #388

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ public T borrowObject(final Duration maxWaitDuration) throws E {
if (PooledObject.isNull(p)) {
try {
remainingWaitDuration = maxWaitDuration.minus(durationSince(startInstant));
p = negativeDuration ? idleObjects.takeFirst() : idleObjects.pollFirst(maxWaitDuration);
p = remainingWaitDuration.isNegative() ? null
: (negativeDuration ? idleObjects.takeFirst() : idleObjects.pollFirst(maxWaitDuration));
} catch (final InterruptedException e) {
// Don't surface exception type of internal locking mechanism.
throw cast(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ public void testBorrowObjectOverrideMaxWaitSmall() throws Exception {
try (final GenericObjectPool<String, InterruptedException> pool = new GenericObjectPool<>(createSlowObjectFactory(Duration.ofSeconds(60)))) {
pool.setMaxTotal(1);
pool.setMaxWait(Duration.ofMillis(1)); // small
pool.setBlockWhenExhausted(false);
pool.setBlockWhenExhausted(true); // need to merge the calculation of wait time
// thread1 tries creating a slow object to make pool full.
final WaitingTestThread<InterruptedException> thread1 = new WaitingTestThread<>(pool, 0);
thread1.start();
Expand Down