Repository: accumulo
Updated Branches:
  refs/heads/1.6 a234def61 -> 1b35d2633
  refs/heads/master 4bbaddcab -> 5640280d8


ACCUMULO-3218 Set the list separator to \0 to 'disable' list interpretation

ZooKeeperInstance, because of how commons-configuration was parsing the
values, was treating a comma separated list of ZK servers (which
we intend to be a single value) as multiple and only returning
the first when getString was called on its key. We have no case
where we actually want values to be automatically parsed into an
array, so we can set it to a separator highly unlikely to be used.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/1b35d263
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/1b35d263
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/1b35d263

Branch: refs/heads/1.6
Commit: 1b35d2633e7558b49a1ff8887a3bc37c19d0b34f
Parents: a234def
Author: Josh Elser <els...@apache.org>
Authored: Thu Oct 9 20:59:03 2014 -0400
Committer: Josh Elser <els...@apache.org>
Committed: Fri Oct 10 14:54:20 2014 -0400

----------------------------------------------------------------------
 .../core/client/ClientConfiguration.java        |  2 ++
 .../core/client/ZooKeeperInstanceTest.java      | 22 ++++++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/1b35d263/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 b64fab4..17ad10b 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
@@ -107,6 +107,8 @@ public class ClientConfiguration extends 
CompositeConfiguration {
 
   public ClientConfiguration(List<? extends Configuration> configs) {
     super(configs);
+    // Don't do list interpolation
+    this.setListDelimiter('\0');
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/accumulo/blob/1b35d263/core/src/test/java/org/apache/accumulo/core/client/ZooKeeperInstanceTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/accumulo/core/client/ZooKeeperInstanceTest.java 
b/core/src/test/java/org/apache/accumulo/core/client/ZooKeeperInstanceTest.java
index 8d86d5a..dde5575 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/client/ZooKeeperInstanceTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/client/ZooKeeperInstanceTest.java
@@ -16,18 +16,20 @@
  */
 package org.apache.accumulo.core.client;
 
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertEquals;
+
 import java.util.List;
 import java.util.UUID;
+
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
 import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.junit.Before;
 import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
 
 public class ZooKeeperInstanceTest {
   private static final UUID IID = UUID.randomUUID();
@@ -140,4 +142,16 @@ public class ZooKeeperInstanceTest {
     replay(zc);
     assertEquals("child2", zki.getInstanceName());
   }
+
+  @Test
+  public void testAllZooKeepersAreUsed() {
+    final String zookeepers = "zk1,zk2,zk3", instanceName = "accumulo";
+    ZooCacheFactory factory = createMock(ZooCacheFactory.class);
+    expect(factory.getZooCache(zookeepers, 30000)).andReturn(zc).anyTimes();
+    replay(factory);
+    ClientConfiguration cfg = 
ClientConfiguration.loadDefault().withInstance(instanceName).withZkHosts(zookeepers);
+    ZooKeeperInstance zki = new ZooKeeperInstance(cfg, factory);
+    assertEquals(zookeepers, zki.getZooKeepers());
+    assertEquals(instanceName, zki.getInstanceName());
+  }
 }

Reply via email to