Skip to content

Commit

Permalink
Make more error codes fail fast during the rediscovery (#1354)
Browse files Browse the repository at this point in the history
  • Loading branch information
injectives authored Dec 15, 2022
1 parent 6b29f12 commit 19a6eaf
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ public class RediscoveryImpl implements Rediscovery {
"Received a recoverable discovery error with server '%s', "
+ "will continue discovery with other routing servers if available. "
+ "Complete failure is reported separately from this entry.";
private static final String INVALID_BOOKMARK_CODE = "Neo.ClientError.Transaction.InvalidBookmark";
private static final String INVALID_BOOKMARK_MIXTURE_CODE = "Neo.ClientError.Transaction.InvalidBookmarkMixture";
private static final String TRANSACTION_INVALID_BOOKMARK_CODE = "Neo.ClientError.Transaction.InvalidBookmark";
private static final String TRANSACTION_INVALID_BOOKMARK_MIXTURE_CODE =
"Neo.ClientError.Transaction.InvalidBookmarkMixture";
private static final String STATEMENT_ARGUMENT_ERROR_CODE = "Neo.ClientError.Statement.ArgumentError";
private static final String REQUEST_INVALID_CODE = "Neo.ClientError.Request.Invalid";
private static final String STATEMENT_TYPE_ERROR_CODE = "Neo.ClientError.Statement.TypeError";

private final BoltServerAddress initialRouter;
private final Logger log;
Expand Down Expand Up @@ -294,7 +298,13 @@ private boolean mustAbortDiscovery(Throwable throwable) {
abort = true;
} else if (throwable instanceof ClientException) {
String code = ((ClientException) throwable).code();
abort = INVALID_BOOKMARK_CODE.equals(code) || INVALID_BOOKMARK_MIXTURE_CODE.equals(code);
abort = switch (code) {
case TRANSACTION_INVALID_BOOKMARK_CODE,
TRANSACTION_INVALID_BOOKMARK_MIXTURE_CODE,
STATEMENT_ARGUMENT_ERROR_CODE,
REQUEST_INVALID_CODE,
STATEMENT_TYPE_ERROR_CODE -> true;
default -> false;};
}

return abort;
Expand Down

0 comments on commit 19a6eaf

Please sign in to comment.