martin-g commented on a change in pull request #400:
URL: https://github.com/apache/curator/pull/400#discussion_r814748733
##########
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:
`#queueEvent(WatchedEvent)` is not available in Zookeeper 3.5.x and this
breaks the build in current `master`:
```
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @
curator-test-zk35 ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
...
[INFO] Running org.apache.curator.framework.state.TestConnectionStateManager
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed:
7.387 s <<< FAILURE! - in
org.apache.curator.framework.state.TestConnectionStateManager
[ERROR]
org.apache.curator.framework.state.TestConnectionStateManager.testConnectionStateRecoversFromUnexpectedExpiredConnection
Time elapsed: 0.489 s <<< ERROR!
java.lang.NoSuchMethodError:
org.apache.zookeeper.Testable.queueEvent(Lorg/apache/zookeeper/WatchedEvent;)V
at
org.apache.curator.framework.state.TestConnectionStateManager.testConnectionStateRecoversFromUnexpectedExpiredConnection(TestConnectionStateManager.java:110)
[INFO] Running org.apache.curator.framework.state.TestConnectionStateManager
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed:
0.124 s <<< FAILURE! - in
org.apache.curator.framework.state.TestConnectionStateManager
[ERROR]
org.apache.curator.framework.state.TestConnectionStateManager.testConnectionStateRecoversFromUnexpectedExpiredConnection
Time elapsed: 0.122 s <<< ERROR!
java.lang.NoSuchMethodError:
org.apache.zookeeper.Testable.queueEvent(Lorg/apache/zookeeper/WatchedEvent;)V
at
org.apache.curator.framework.state.TestConnectionStateManager.testConnectionStateRecoversFromUnexpectedExpiredConnection(TestConnectionStateManager.java:110)
...
```
--
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]