Github user rakeshadr commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/156#discussion_r98146418
  
    --- Diff: src/java/test/org/apache/zookeeper/server/NIOServerCnxnTest.java 
---
    @@ -68,4 +69,41 @@ public void testOperationsAfterCnxnClose() throws 
IOException,
                 zk.close();
             }
         }
    +
    +    /**
    +     * Mock extension of NIOServerCnxn to test for
    +     * CancelledKeyException (ZOOKEEPER-2044).
    +     */
    +    private static class MockNIOServerCnxn extends NIOServerCnxn {
    +        public MockNIOServerCnxn(NIOServerCnxn cnxn)
    +                throws IOException {
    +            super(cnxn.zkServer, cnxn.sock, cnxn.sk, cnxn.factory);
    +        }
    +
    +        public void mockSendBuffer(ByteBuffer bb) throws Exception {
    +            super.internalSendBuffer(bb);
    +        }
    +    }
    +
    +    @Test(timeout = 30000)
    +    public void testValidSelectionKey() throws Exception {
    +        int oldTimeout = ClientBase.CONNECTION_TIMEOUT;
    +        ClientBase.CONNECTION_TIMEOUT = 3000;
    +        final ZooKeeper zk = createClient();
    --- End diff --
    
    Thanks @hanm for the analysis and fixing it. Instead of directly changing 
the static value, how about simplifying the ZooKeeper client creation like 
below,
    
    ``final ZooKeeper zk = createZKClient(hostPort, 3000);``


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to