martin-g commented on a change in pull request #400:
URL: https://github.com/apache/curator/pull/400#discussion_r814762078
##########
File path:
curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java
##########
@@ -83,4 +89,43 @@ public void stateChanged(CuratorFramework client,
ConnectionState newState)
CloseableUtils.closeQuietly(client);
}
}
+
+ @Test
+ public void testConnectionStateRecoversFromUnexpectedExpiredConnection()
throws Exception {
+ Timing2 timing = new Timing2();
+ CuratorFramework client = CuratorFrameworkFactory.builder()
+ .connectString(server.getConnectString())
+ .connectionTimeoutMs(1_000)
+ .sessionTimeoutMs(250) // try to aggressively expire the
connection
+ .retryPolicy(new RetryOneTime(1))
+ .connectionStateErrorPolicy(new
SessionConnectionStateErrorPolicy())
+ .build();
+ final BlockingQueue<ConnectionState> queue =
Queues.newLinkedBlockingQueue();
+ ConnectionStateListener listener = (client1, state) ->
queue.add(state);
+ client.getConnectionStateListenable().addListener(listener);
+ client.start();
+ try {
+ ConnectionState polled = queue.poll(timing.forWaiting().seconds(),
TimeUnit.SECONDS);
+ assertEquals(polled, ConnectionState.CONNECTED);
+
client.getZookeeperClient().getZooKeeper().getTestable().queueEvent(new
WatchedEvent(
Review comment:
Possible fix: https://github.com/apache/curator/pull/409
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]