From 19a6eafad84b8d1df00d95b4968cf4eff03af110 Mon Sep 17 00:00:00 2001 From: Dmitriy Tverdiakov <11927660+injectives@users.noreply.github.com> Date: Thu, 15 Dec 2022 09:24:12 +0000 Subject: [PATCH] Make more error codes fail fast during the rediscovery (#1354) https://github.com/neo4j-drivers/testkit/pull/536 --- .../driver/internal/cluster/RediscoveryImpl.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/driver/src/main/java/org/neo4j/driver/internal/cluster/RediscoveryImpl.java b/driver/src/main/java/org/neo4j/driver/internal/cluster/RediscoveryImpl.java index e734f4a6a3..9d58ed32f2 100644 --- a/driver/src/main/java/org/neo4j/driver/internal/cluster/RediscoveryImpl.java +++ b/driver/src/main/java/org/neo4j/driver/internal/cluster/RediscoveryImpl.java @@ -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; @@ -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;