Skip to content

Commit 743091e

Browse files
authored
Update ExponentialBackoffRetryLogic (#1603)
This update ensures that a failed transaction error is handled appropriately by the logic.
1 parent 9f585b5 commit 743091e

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

driver/src/main/java/org/neo4j/driver/internal/retry/ExponentialBackoffRetryLogic.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@
3030
import java.util.function.Supplier;
3131
import org.neo4j.driver.Logger;
3232
import org.neo4j.driver.Logging;
33-
import org.neo4j.driver.exceptions.ClientException;
3433
import org.neo4j.driver.exceptions.Neo4jException;
3534
import org.neo4j.driver.exceptions.RetryableException;
36-
import org.neo4j.driver.exceptions.SecurityRetryableException;
35+
import org.neo4j.driver.exceptions.TransactionTerminatedException;
3736
import org.neo4j.driver.internal.util.Futures;
3837
import org.reactivestreams.Publisher;
3938
import reactor.core.publisher.Flux;
@@ -161,10 +160,7 @@ protected boolean canRetryOn(Throwable error) {
161160
* @return the possible cause or the original error
162161
*/
163162
private static Throwable extractPossibleTerminationCause(Throwable error) {
164-
// Having a dedicated "TerminatedException" inheriting from ClientException might be a good idea.
165-
if (!(error instanceof SecurityRetryableException)
166-
&& error instanceof ClientException
167-
&& error.getCause() != null) {
163+
if (error instanceof TransactionTerminatedException && error.getCause() != null) {
168164
return error.getCause();
169165
}
170166
return error;

driver/src/test/java/org/neo4j/driver/internal/retry/ExponentialBackoffRetryLogicTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import org.neo4j.driver.exceptions.ConnectionReadTimeoutException;
6969
import org.neo4j.driver.exceptions.ServiceUnavailableException;
7070
import org.neo4j.driver.exceptions.SessionExpiredException;
71+
import org.neo4j.driver.exceptions.TransactionTerminatedException;
7172
import org.neo4j.driver.exceptions.TransientException;
7273
import org.neo4j.driver.internal.util.ImmediateSchedulingEventExecutor;
7374
import org.reactivestreams.Publisher;
@@ -1300,7 +1301,7 @@ private static ServiceUnavailableException serviceUnavailable() {
13001301
}
13011302

13021303
private static RuntimeException clientExceptionWithValidTerminationCause() {
1303-
return new ClientException(\\_(ツ)_/¯", serviceUnavailable());
1304+
return new TransactionTerminatedException(\\_(ツ)_/¯", serviceUnavailable());
13041305
}
13051306

13061307
private static RuntimeException randomClientException() {

0 commit comments

Comments
 (0)