Russole commented on code in PR #23436:
URL: https://github.com/apache/kafka/pull/23436#discussion_r4000111865


##########
clients/src/main/java/org/apache/kafka/common/protocol/MessageUtil.java:
##########
@@ -111,55 +111,19 @@ public static long jsonNodeToUnsignedInt(JsonNode node, 
String about) {
     }
 
     public static int jsonNodeToInt(JsonNode node, String about) {
-        if (node.isInt()) {
-            return node.asInt();
-        }
-        if (node.isTextual()) {
-            throw new NumberFormatException(about + ": expected an integer or 
" +
-                "string type, but got " + node.getNodeType());
-        }
-        String text = node.asText();
-        if (text.startsWith("0x")) {
-            try {
-                return Integer.parseInt(text.substring(2), 16);
-            } catch (NumberFormatException e) {
-                throw new NumberFormatException(about + ": failed to " +
-                    "parse hexadecimal number: " + e.getMessage());
-            }
-        } else {
-            try {
-                return Integer.parseInt(text);
-            } catch (NumberFormatException e) {
-                throw new NumberFormatException(about + ": failed to " +
-                    "parse number: " + e.getMessage());
-            }
+        if (!node.isIntegralNumber() || !node.canConvertToInt()) {

Review Comment:
   Good point. I’ve updated them to use separate messages for invalid types and 
out-of-range values.



-- 
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