[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-1174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13101642#comment-13101642
 ] 

Ted Dunning commented on ZOOKEEPER-1174:
----------------------------------------

Mocking the test sounds great.  Using this bug to bring in a mocking technology 
that can mock
static methods is a little more ambitious than I wanted it to be.

I see that jmockit and powermock both claim the ability to do this.  Powermock 
requires another
mocking technology underneath.  Jmockit has the problem that it isn't available 
in an official
maven repo.

My tendency is to suggest that we commit this without the unit test and open 
another JIRA to address
the testing problem in general.

If I can get sign-off on that, then I will produce a final patch to verify.  
The code right now stands
like this:
{code}
        try {
            boolean immediateConnect = sock.connect(addr);
            sockKey = sock.register(selector, SelectionKey.OP_CONNECT);
            if (immediateConnect) {
                sendThread.primeConnection();
            }
        } catch (IOException e) {
            sock.close();
        }
        initialized = false;
{code}


> FD leak when network unreachable
> --------------------------------
>
>                 Key: ZOOKEEPER-1174
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1174
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: java client
>    Affects Versions: 3.3.3
>            Reporter: Ted Dunning
>            Assignee: Ted Dunning
>            Priority: Critical
>             Fix For: 3.3.4
>
>         Attachments: ZOOKEEPER-1174.patch, ZOOKEEPER-1174.patch, 
> ZOOKEEPER-1174.patch, ZOOKEEPER-1174.patch, zk-fd-leak.tgz
>
>
> In the socket connection logic there are several errors that result in bad 
> behavior.  The basic problem is that a socket is registered with a selector 
> unconditionally when there are nuances that should be dealt with.  First, the 
> socket may connect immediately.  Secondly, the connect may throw an 
> exception.  In either of these two cases, I don't think that the socket 
> should be registered.
> I will attach a test case that demonstrates the problem.  I have been unable 
> to create a unit test that exhibits the problem because I would have to mock 
> the low level socket libraries to do so.  It would still be good to do so if 
> somebody can figure out a good way.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to