You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2020/01/17 05:11:52 UTC

[GitHub] [zookeeper] sujithsimon22 commented on a change in pull request #1222: ZOOKEEPER-3667: Set jute.maxbuffer hexadecimal number throw parseInt error

sujithsimon22 commented on a change in pull request #1222: ZOOKEEPER-3667: Set jute.maxbuffer hexadecimal number throw parseInt error
URL: https://github.com/apache/zookeeper/pull/1222#discussion_r367771889
 
 

 ##########
 File path: zookeeper-server/src/test/java/org/apache/zookeeper/client/ZKClientConfigTest.java
 ##########
 @@ -185,4 +185,35 @@ public void testIntegerRetrievalFromProperty() {
         assertEquals(value, result);
     }
 
+    @Test
+    public void testIntegerRetrievalFromHexadecimalProperty() {
+        int hexaValue = 0x3000000;
+        String wrongValue = "0xwel";
+        int defaultValue = 100;
+        // property is set in hexadecimal value
+        ZKClientConfig zkClientConfig = new ZKClientConfig();
+        zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER,
+                Integer.toString(hexaValue));
+        int result = zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue);
+        assertEquals(result, hexaValue);
+        zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER,
+                wrongValue);
+        try {
+            result = zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue);
+            fail("NumberFormatException is expected");
+        } catch (NumberFormatException exception) {
+            // do nothing
+        }
+        zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER,
+                " " + hexaValue + " ");
+        zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue);
+        assertEquals(result, hexaValue);
+        zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER, " " + hexaValue);
 
 Review comment:
   Done, thanks

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services