refactor: Improve retry predicate by delegating to the driver first.

This commit is contained in:
Michael Simons
2024-03-18 14:41:58 +01:00
parent ddde992ad8
commit 0132bdd97f

View File

@@ -20,6 +20,7 @@ import java.util.function.Predicate;
import org.apiguardian.api.API;
import org.neo4j.driver.exceptions.DiscoveryException;
import org.neo4j.driver.exceptions.RetryableException;
import org.neo4j.driver.exceptions.ServiceUnavailableException;
import org.neo4j.driver.exceptions.SessionExpiredException;
import org.neo4j.driver.exceptions.TransientException;
@@ -43,6 +44,10 @@ public final class RetryExceptionPredicate implements Predicate<Throwable> {
@Override
public boolean test(Throwable throwable) {
if (throwable instanceof RetryableException) {
return true;
}
if (throwable instanceof IllegalStateException) {
String msg = throwable.getMessage();
return msg != null && RETRYABLE_ILLEGAL_STATE_MESSAGES.contains(msg);