Skip to content

Commit 20780dd

Browse files
committed
Make canRetryOn function public.
Make it static and rename it to isRetryable. To be used as experimental API.
1 parent cecf1bb commit 20780dd

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import io.netty.util.concurrent.EventExecutor;
2222
import io.netty.util.concurrent.EventExecutorGroup;
23+
24+
import org.neo4j.driver.util.Experimental;
2325
import org.reactivestreams.Publisher;
2426
import reactor.core.publisher.Flux;
2527
import reactor.core.publisher.Mono;
@@ -104,7 +106,7 @@ public <T> T retry( Supplier<T> work )
104106
catch ( Throwable throwable )
105107
{
106108
Throwable error = extractPossibleTerminationCause( throwable );
107-
if ( canRetryOn( error ) )
109+
if ( isRetryable( error ) )
108110
{
109111
long currentTime = clock.millis();
110112
if ( startTime == -1 )
@@ -146,7 +148,8 @@ public <T> Publisher<T> retryRx( Publisher<T> work )
146148
return Flux.from( work ).retryWhen( retryRxCondition() );
147149
}
148150

149-
protected boolean canRetryOn( Throwable error )
151+
@Experimental
152+
public static boolean isRetryable( Throwable error )
150153
{
151154
return error instanceof SessionExpiredException || error instanceof ServiceUnavailableException || isTransientError( error );
152155
}
@@ -183,7 +186,7 @@ private Function<Flux<Throwable>,Publisher<Context>> retryRxCondition()
183186
long startTime = ctx.getOrDefault( "startTime", -1L );
184187
long nextDelayMs = ctx.getOrDefault( "nextDelayMs", initialRetryDelayMs );
185188

186-
if ( canRetryOn( error ) )
189+
if ( isRetryable( error ) )
187190
{
188191
long currentTime = clock.millis();
189192
if ( startTime == -1 )
@@ -270,7 +273,7 @@ private <T> void retryOnError( CompletableFuture<T> resultFuture, Supplier<Compl
270273
List<Throwable> errors )
271274
{
272275
Throwable error = extractPossibleTerminationCause( throwable );
273-
if ( canRetryOn( error ) )
276+
if ( isRetryable( error ) )
274277
{
275278
long currentTime = clock.millis();
276279
if ( startTime == -1 )

0 commit comments

Comments
 (0)