Uploaded image for project: 'Apache Curator'
  1. Apache Curator
  2. CURATOR-59

ConnectionState.CONNECTED can get set incorrectly

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0-incubating
    • Fix Version/s: 2.3.0
    • Component/s: Framework
    • Labels:
      None

      Description

      If the client is never able to connect to a server, it will incorrectly set ConnectionState.CONNECTED.

      Example:

          @Test
          public void testNeverConnected() throws Exception
          {
              PersistentEphemeralNode persistentEphemeralNode = null;
              // use a connection string to a non-existent server
              CuratorFramework client = CuratorFrameworkFactory.newClient("localhost:1111", 100, 100, new RetryOneTime(1));
              try
              {
                  final BlockingQueue<ConnectionState> queue = Queues.newLinkedBlockingQueue();
                  ConnectionStateListener listener = new ConnectionStateListener()
                  {
                      @Override
                      public void stateChanged(CuratorFramework client, ConnectionState state)
                      {
                          queue.add(state);
                      }
                  };
                  client.getConnectionStateListenable().addListener(listener);
                  client.start();
      
                  // use a recipe that continuously retries
                  persistentEphemeralNode = new PersistentEphemeralNode(client, PersistentEphemeralNode.Mode.EPHEMERAL, "/abc/pen", "hello".getBytes());
                  persistentEphemeralNode.start();
      
                  Assert.assertEquals(queue.take(), ConnectionState.LOST);
              }
              finally
              {
                  Closeables.closeQuietly(persistentEphemeralNode);
                  Closeables.closeQuietly(client);
              }
          }
      

        Attachments

          Activity

            People

            • Assignee:
              randgalt Jordan Zimmerman
              Reporter:
              randgalt Jordan Zimmerman
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: