Skip to content

Commit ec24f3d

Browse files
fix - ReconnectToWriterHandler success flag by fixing isCurrentHostWriter()(#323)
Fix isCurrentHostWrite() which the ReconnectToWriterHandler success flag uses. Added more checks on host aliases fields to make it more robust
1 parent e4ce413 commit ec24f3d

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

wrapper/src/main/java/software/amazon/jdbc/plugin/failover/ClusterAwareWriterFailoverHandler.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,12 @@ public WriterFailoverResult call() {
293293
}
294294

295295
private boolean isCurrentHostWriter(final List<HostSpec> latestTopology) {
296-
final Set<String> currentAliases = this.originalWriterHost.getAliases();
297296
final HostSpec latestWriter = getWriter(latestTopology);
298-
if (currentAliases == null) {
299-
return false;
300-
}
301-
final Set<String> latestWriterAliases = latestWriter.getAliases();
297+
final Set<String> latestWriterAllAliases = latestWriter.asAliases();
298+
final Set<String> currentAliases = this.originalWriterHost.getAliases();
302299

303-
return latestWriterAliases.stream().anyMatch(currentAliases::contains);
300+
return (currentAliases != null)
301+
&& (latestWriterAllAliases.stream().anyMatch(currentAliases::contains));
304302
}
305303
}
306304

wrapper/src/main/java/software/amazon/jdbc/plugin/failover/FailoverConnectionPlugin.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,5 +797,4 @@ public Connection connect(
797797

798798
return conn;
799799
}
800-
801800
}

0 commit comments

Comments
 (0)