Skip to content
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 @@ -479,8 +479,10 @@ protected void runChecks() {
// Kill adder thread and set up to true
upStart = Instant.now();
up = true;
adder.kill();
adder = null;
if (adder != null) {
adder.kill();
adder = null;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
*/
package org.apache.commons.pool3.impl;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.time.Duration;
Expand Down Expand Up @@ -257,6 +259,30 @@ public void run() {
assertFalse(rf.isMonitorRunning());
}

@Test
void testRecoveryWithoutAdderDoesNotThrowWhenFactoryComesBackUp() throws Exception {
final FailingFactory ff = new FailingFactory();
ff.setSilentFail(false);
final ResilientPooledObjectFactory<String, Exception> rf = new ResilientPooledObjectFactory<>(ff,
2, Duration.ofMillis(10), Duration.ofMinutes(10), Duration.ofMillis(10));
final GenericObjectPool<String, Exception> pool = new GenericObjectPool<>(rf);
rf.setPool(pool);

ff.crash();
assertThrows(Exception.class, rf::makeObject);
rf.runChecks();
assertFalse(rf.isUp());
assertFalse(rf.isAdderRunning());

ff.recover();
rf.makeObject();
rf.makeObject();
assertDoesNotThrow(rf::runChecks);
assertTrue(rf.isUp());
assertFalse(rf.isAdderRunning());
pool.close();
}

@Test
void testTransientFailure() throws Exception {
final FailingFactory ff = new FailingFactory();
Expand Down