Skip to content

Commit

Permalink
change 'isShortSrvHost' to 'srvHostHasLessThanThreeParts' and remove …
Browse files Browse the repository at this point in the history
…redundant code comment as per code review comment
  • Loading branch information
NathanQingyangXu committed Oct 21, 2024
1 parent 49ee4c4 commit 1e918ad
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public List<String> resolveHostFromSrvRecords(final String srvHost, final String
List<String> srvHostParts = asList(srvHost.split("\\."));

String srvHostDomain;
boolean isShortSrvHost = srvHostParts.size() < 3;
if (isShortSrvHost) {
srvHostDomain = srvHost; // when dot separated parts less than 3, domain name is the host per se
boolean srvHostHasLessThanThreeParts = srvHostParts.size() < 3;
if (srvHostHasLessThanThreeParts) {
srvHostDomain = srvHost;
} else {
srvHostDomain = srvHost.substring(srvHost.indexOf('.') + 1);
}
Expand All @@ -89,7 +89,7 @@ public List<String> resolveHostFromSrvRecords(final String srvHost, final String
for (String srvRecord : srvAttributeValues) {
String[] split = srvRecord.split(" ");
String resolvedHost = split[3].endsWith(".") ? split[3].substring(0, split[3].length() - 1) : split[3];
if (isShortSrvHost && resolvedHost.equals(srvHost)) {
if (srvHostHasLessThanThreeParts && resolvedHost.equals(srvHost)) {
throw new MongoConfigurationException(
format("The SRV host name '%s' has less than three parts and the resolved host '%s' is identical.",
srvHost, resolvedHost)
Expand Down

0 comments on commit 1e918ad

Please sign in to comment.