You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "xsank mar (JIRA)" <ji...@apache.org> on 2016/12/22 02:55:59 UTC
[jira] [Created] (CURATOR-368) powermock will cause curator
CONNECTIONLOSS exception
xsank mar created CURATOR-368:
---------------------------------
Summary: powermock will cause curator CONNECTIONLOSS exception
Key: CURATOR-368
URL: https://issues.apache.org/jira/browse/CURATOR-368
Project: Apache Curator
Issue Type: Bug
Components: Framework
Environment: window & linux
jdk 1.7
curator-framework 2.9.1
curator-recipe 2.9.1
curator-test 2.9.1
junit 4.12
powermock-module-junit4 1.6.1
powermock-api-mockito 1.6.1
Reporter: xsank mar
Priority: Critical
client code
{code}
public class CuratorClient {
private CuratorFramework client;
public CuratorClient(String url) {
this.client = CuratorFrameworkFactory.builder().connectString(url).namespace("test")
.retryPolicy(new RetryNTimes(3, 5000))
.connectionTimeoutMs(3000).build();
this.client.start();
}
public void create(String path) {
try {
this.client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(path);
} catch (Exception e) {
e.printStackTrace();
}
}
public void lsChildren(String path) {
try {
List<String> children = this.client.getChildren().forPath(path);
for (String child : children) {
System.out.println(child);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void close() {
this.client.close();
}
}
{code}
Test code
{code}
@RunWith(PowerMockRunner.class)
@PrepareForTest({Static.class})
public class CuratorTest {
private CuratorClient client;
private TestingServer server;
@Before
public void setUp() throws Exception {
server = new TestingServer();
server.start();
client = new CuratorClient(server.getConnectString());
}
@After
public void tearDown() throws Exception {
client.close();
server.close();
}
@Test
public void testCreate() throws Exception {
client.create("/curator");
}
@Test
public void lsChildren() throws Exception {
client.lsChildren("/curator");
}
}
{code}
now start testing, you will catch the exception everytime:
{code}
org.apache.curator.CuratorConnectionLossException: KeeperErrorCode = ConnectionLoss
at org.apache.curator.ConnectionState.checkTimeouts(ConnectionState.java:195)
at org.apache.curator.ConnectionState.getZooKeeper(ConnectionState.java:87)
at org.apache.curator.CuratorZookeeperClient.getZooKeeper(CuratorZookeeperClient.java:115)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.getZooKeeper(CuratorFrameworkImpl.java:487)
at org.apache.curator.framework.imps.CreateBuilderImpl$11.call(CreateBuilderImpl.java:720)
at org.apache.curator.framework.imps.CreateBuilderImpl$11.call(CreateBuilderImpl.java:703)
at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:107)
at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:699)
at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:477)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:467)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:447)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:44)
at org.alibaba.search.client.CuratorClient.create(CuratorClient.java:25)
at org.alibaba.search.client.CuratorTest.testCreate(CuratorTest.java:35)
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)