Skip to content

Commit

Permalink
feat: HostSpec to not default lastUpdateTime. Handle null lastUpdateT…
Browse files Browse the repository at this point in the history
…ime in RdsHostListProvider
  • Loading branch information
aaronchung-bitquill committed Feb 8, 2024
1 parent cdc555f commit 06da9df
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public HostSpecBuilder lastUpdateTime(Timestamp lastUpdateTime) {

public HostSpec build() {
checkHostIsSet();
setDefaultLastUpdateTime();
return new HostSpec(this.host, this.port, this.hostId, this.role, this.availability,
this.weight, this.lastUpdateTime, this.hostAvailabilityStrategy);
}
Expand All @@ -99,10 +98,4 @@ private void checkHostIsSet() {
throw new IllegalArgumentException("host parameter must be set.");
}
}

private void setDefaultLastUpdateTime() {
if (this.lastUpdateTime == null) {
this.lastUpdateTime = Timestamp.from(Instant.now());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ private List<HostSpec> processQueryResults(final ResultSet resultSet) throws SQL
} else {
// Take the latest updated writer node as the current writer. All others will be ignored.
List<HostSpec> sortedWriters = writers.stream()
.sorted(Comparator.comparing(HostSpec::getLastUpdateTime).reversed())
.sorted(Comparator.comparing(HostSpec::getLastUpdateTime, Comparator.nullsLast(Comparator.reverseOrder())))
.collect(Collectors.toList());
hosts.add(sortedWriters.get(0));
}
Expand Down

0 comments on commit 06da9df

Please sign in to comment.