dschneider-pivotal commented on a change in pull request #6765:
URL: https://github.com/apache/geode/pull/6765#discussion_r692668692



##########
File path: 
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/netty/Coder.java
##########
@@ -332,9 +343,55 @@ public static BigDecimal bytesToBigDecimal(byte[] bytes) {
   }
 
   public static long bytesToLong(byte[] bytes) {
-    return Long.parseLong(bytesToString(bytes));
+    return parseLong(bytes);
+  }
+
+  private static NumberFormatException createNumberFormatException(byte[] 
bytes) {
+    return new NumberFormatException("For input string: \"" + 
bytesToString(bytes) + "\"");
+  }
+
+  /**
+   * This method was derived from openjdk Long.java parseLong
+   */
+  public static long parseLong(byte[] bytes) throws NumberFormatException {
+    final int len = bytes.length;
+    if (len <= 0) {
+      throw createNumberFormatException(bytes);
+    }
+    int i = 0;
+    long limit = -Long.MAX_VALUE;
+    boolean negative = false;
+    byte firstByte = bytes[0];
+    if (firstByte < NUMBER_0_BYTE) { // Possible leading "+" or "-"
+      if (firstByte == bMINUS) {
+        negative = true;
+        limit = Long.MIN_VALUE;
+      } else if (firstByte != bPLUS) {

Review comment:
       lets do that on another ticket. It does seem we might get some other 
benefits of having our own code to do the conversion instead of just using the 
jdk. 




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to