absurdfarce commented on code in PR #2013:
URL: 
https://github.com/apache/cassandra-java-driver/pull/2013#discussion_r2127402217


##########
core/src/main/java/com/datastax/oss/driver/internal/core/addresstranslation/Subnet.java:
##########
@@ -0,0 +1,157 @@
+package com.datastax.oss.driver.internal.core.addresstranslation;
+
+import 
com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+
+class Subnet {
+  private final byte[] subnet;
+  private final byte[] networkMask;
+  private final byte[] upper;
+  private final byte[] lower;
+
+  private Subnet(byte[] subnet, byte[] networkMask) {
+    this.subnet = subnet;
+    this.networkMask = networkMask;
+
+    byte[] upper = new byte[subnet.length];
+    byte[] lower = new byte[subnet.length];
+    for (int i = 0; i < subnet.length; i++) {
+      upper[i] = (byte) (subnet[i] | ~networkMask[i]);
+      lower[i] = (byte) (subnet[i] & networkMask[i]);
+    }
+    this.upper = upper;
+    this.lower = lower;
+  }
+
+  static Subnet parse(String subnetCIDR) throws UnknownHostException {
+    String[] parts = subnetCIDR.split("/");

Review Comment:
   Errorprone complains about this line when building due to [known issues with 
String.split()](https://errorprone.info/bugpattern/StringSplitter).  
Recommendation is to replace this with:
   
   ```java
   List<String> parts = Splitter.on('/').splitToList(subnetCIDR);
   ```
   
   I used something slightly different to preserve the `String[]` type 
throughout the rest of the code and it seemed to work fine:
   
   ```java
       String[] parts = Iterables.toArray(Splitter.on('/').split(subnetCIDR), 
String.class);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to