#65 Patch to fix NPE upon access to watcher

closed-fixed
java client (7)
7
2008-05-06
2008-05-06
fpj
No

This patch is related to bug reports 1956937 and 1941629.

There is a race condition in the ZooKeeper constructor. In the current version, the constructor creates ClientCnxn before it sets the watcher attribute, which causes a NullPoiterException to be thrown. This patch just inverts the order of instantiating ClientCnxn and assigning a value to the watcher attribute.

-Flavio

Discussion

  • Patrick Hunt

    Patrick Hunt - 2008-05-06

    Logged In: YES
    user_id=12853
    Originator: NO

    Moving to patches rather than bug list.

     
  • Patrick Hunt

    Patrick Hunt - 2008-05-06

    Logged In: YES
    user_id=12853
    Originator: NO

    The assignee is responsible for closing (committing) this patch (see ZooKeeperPatches on wiki) -- this includes getting additional review if necessary.

     
  • Patrick Hunt

    Patrick Hunt - 2008-05-06
    • labels: --> java client
    • priority: 5 --> 7
    • assigned_to: nobody --> breed
     
  • Patrick Hunt

    Patrick Hunt - 2008-05-06

    Logged In: YES
    user_id=12853
    Originator: NO

    +1

    Note: findbugs actually flags clientcnxn for this exact problem. findbugs doesn't like the fact that clientcnxn is starting threads in the constructor. Perhaps we should enter a bug - have a separate method (sep from constructor) that starts the connection, to be called after constructor returns. I'm good with committing this patch though.

     
  • fpj

    fpj - 2008-05-06

    Makes attribute volatile as well.

     
  • fpj

    fpj - 2008-05-06

    Logged In: YES
    user_id=1926444
    Originator: YES

    File Added: patch-npe-zk

     
  • Benjamin Reed

    Benjamin Reed - 2008-05-06

    Logged In: YES
    user_id=154690
    Originator: NO

    +1 creating ClientCnxn in the constructor is a separate issue. (There are a bunch of these in the code.)

     
  • Benjamin Reed

    Benjamin Reed - 2008-05-06

    Logged In: YES
    user_id=154690
    Originator: NO

    Committed revision 150.

     
  • Benjamin Reed

    Benjamin Reed - 2008-05-06
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks