Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 61732173C6 for ; Thu, 23 Apr 2015 13:42:30 +0000 (UTC) Received: (qmail 69260 invoked by uid 500); 23 Apr 2015 13:42:30 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 69229 invoked by uid 500); 23 Apr 2015 13:42:30 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 69220 invoked by uid 99); 23 Apr 2015 13:42:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Apr 2015 13:42:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9C1A1E1789; Thu, 23 Apr 2015 13:42:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: billie@apache.org To: commits@accumulo.apache.org Message-Id: <4a063bd3015f484d92e8a16fb2d31a39@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: accumulo git commit: ACCUMULO-3746 fix ClientConfiguration.getAllPropertiesWithPrefix and add test Date: Thu, 23 Apr 2015 13:42:29 +0000 (UTC) Repository: accumulo Updated Branches: refs/heads/1.7 312b8762d -> 47c64d9a0 ACCUMULO-3746 fix ClientConfiguration.getAllPropertiesWithPrefix and add test Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/47c64d9a Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/47c64d9a Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/47c64d9a Branch: refs/heads/1.7 Commit: 47c64d9a0e161f4083749e05dcbd015ab9e5d2a4 Parents: 312b876 Author: Billie Rinaldi Authored: Thu Apr 23 06:01:12 2015 -0700 Committer: Billie Rinaldi Committed: Thu Apr 23 06:01:12 2015 -0700 ---------------------------------------------------------------------- .../accumulo/core/client/ClientConfiguration.java | 8 ++++++-- .../accumulo/core/client/ClientConfigurationTest.java | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/47c64d9a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java index a926d35..7aab80c 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java +++ b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java @@ -302,8 +302,12 @@ public class ClientConfiguration extends CompositeConfiguration { public Map getAllPropertiesWithPrefix(ClientProperty property) { checkType(property, PropertyType.PREFIX); - Map propMap = new HashMap(); - Iterator iter = this.getKeys(property.getKey()); + Map propMap = new HashMap<>(); + String prefix = property.getKey(); + if (prefix.endsWith(".")) { + prefix = prefix.substring(0, prefix.length() - 1); + } + Iterator iter = this.getKeys(prefix); while (iter.hasNext()) { String p = (String) iter.next(); propMap.put(p, getString(p)); http://git-wip-us.apache.org/repos/asf/accumulo/blob/47c64d9a/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java index 225298b..3e8e0f3 100644 --- a/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java +++ b/core/src/test/java/org/apache/accumulo/core/client/ClientConfigurationTest.java @@ -123,4 +123,17 @@ public class ClientConfigurationTest { assertEquals(val, conf.get(ClientProperty.TRACE_SPAN_RECEIVERS)); assertEquals(1, conf.getList(ClientProperty.TRACE_SPAN_RECEIVERS.getKey()).size()); } + + @Test + public void testGetAllPropertiesWithPrefix() { + ClientConfiguration conf = new ClientConfiguration(); + conf.addProperty(ClientProperty.TRACE_SPAN_RECEIVER_PREFIX.getKey() + "first", "1st"); + conf.addProperty(ClientProperty.TRACE_SPAN_RECEIVER_PREFIX.getKey() + "second", "2nd"); + conf.addProperty("other", "value"); + + Map props = conf.getAllPropertiesWithPrefix(ClientProperty.TRACE_SPAN_RECEIVER_PREFIX); + assertEquals(2, props.size()); + assertEquals("1st", props.get(ClientProperty.TRACE_SPAN_RECEIVER_PREFIX.getKey() + "first")); + assertEquals("2nd", props.get(ClientProperty.TRACE_SPAN_RECEIVER_PREFIX.getKey() + "second")); + } }