From commits-return-8108-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Mon Jan 20 07:41:41 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 88CAB18037A for ; Mon, 20 Jan 2020 08:41:41 +0100 (CET) Received: (qmail 14778 invoked by uid 500); 20 Jan 2020 07:41:40 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 14766 invoked by uid 99); 20 Jan 2020 07:41:40 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jan 2020 07:41:40 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 91867819D2; Mon, 20 Jan 2020 07:41:40 +0000 (UTC) Date: Mon, 20 Jan 2020 07:41:40 +0000 To: "commits@zookeeper.apache.org" Subject: [zookeeper] branch branch-3.5 updated: ZOOKEEPER-3667: Setting jute.maxbuffer value in hexadecimal throws Exception MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <157950610045.1802.1547180783745647155@gitbox.apache.org> From: arshad@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: zookeeper X-Git-Refname: refs/heads/branch-3.5 X-Git-Reftype: branch X-Git-Oldrev: df1dc8204fdb79276f10169fbd115f24012f4b21 X-Git-Newrev: 4a20176e4c48fe32c60272ba4bd6aeac490bc0e7 X-Git-Rev: 4a20176e4c48fe32c60272ba4bd6aeac490bc0e7 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. arshad pushed a commit to branch branch-3.5 in repository https://gitbox.apache.org/repos/asf/zookeeper.git The following commit(s) were added to refs/heads/branch-3.5 by this push: new 4a20176 ZOOKEEPER-3667: Setting jute.maxbuffer value in hexadecimal throws Exception 4a20176 is described below commit 4a20176e4c48fe32c60272ba4bd6aeac490bc0e7 Author: Sujith Simon AuthorDate: Mon Jan 20 13:09:29 2020 +0530 ZOOKEEPER-3667: Setting jute.maxbuffer value in hexadecimal throws Exception Author: sujithsimon22 Reviewers: Mohammad Arshad Closes #1222 from sujithsimon22/3667 (cherry picked from commit 49ad75b18bfe26e853050f5add6f10f567399058) Signed-off-by: Mohammad Arshad --- .../java/org/apache/zookeeper/common/ZKConfig.java | 2 +- .../zookeeper/client/ZKClientConfigTest.java | 25 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/common/ZKConfig.java b/zookeeper-server/src/main/java/org/apache/zookeeper/common/ZKConfig.java index 43bc2d8..3d18977 100644 --- a/zookeeper-server/src/main/java/org/apache/zookeeper/common/ZKConfig.java +++ b/zookeeper-server/src/main/java/org/apache/zookeeper/common/ZKConfig.java @@ -289,7 +289,7 @@ public class ZKConfig { public int getInt(String key, int defaultValue) { String value = getProperty(key); if (value != null) { - return Integer.parseInt(value.trim()); + return Integer.decode(value.trim()); } return defaultValue; } diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/client/ZKClientConfigTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/client/ZKClientConfigTest.java index 00a57f4..6d3cfbd 100644 --- a/zookeeper-server/src/test/java/org/apache/zookeeper/client/ZKClientConfigTest.java +++ b/zookeeper-server/src/test/java/org/apache/zookeeper/client/ZKClientConfigTest.java @@ -188,4 +188,29 @@ public class ZKClientConfigTest { 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 + " "); + result = zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue); + assertEquals(result, hexaValue); + } + }