Repository: accumulo Updated Branches: refs/heads/master 58cfee84d -> dd01cbfae
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/master Commit: 47c64d9a0e161f4083749e05dcbd015ab9e5d2a4 Parents: 312b876 Author: Billie Rinaldi <bil...@apache.org> Authored: Thu Apr 23 06:01:12 2015 -0700 Committer: Billie Rinaldi <bil...@apache.org> 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<String,String> getAllPropertiesWithPrefix(ClientProperty property) { checkType(property, PropertyType.PREFIX); - Map<String,String> propMap = new HashMap<String,String>(); - Iterator<?> iter = this.getKeys(property.getKey()); + Map<String,String> 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<String, String> 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")); + } }