@Test
  public void testBug39332() {
    // create client cache and Send clientReady message
    createCacheClient(2, 20);
    HashSet redundantServers = new HashSet(pool.getRedundantNames());
    redundantServers.add(pool.getPrimaryName());

    instance.determineAndVerfiyRedundantServers(redundantServers);
    instance.determineAndVerfiyNonRedundantServers(redundantServers);

    LogWriterUtils.getLogWriter()
        .info("TEST - Durable client initialially has servers " + redundantServers);

    LogWriterUtils.getLogWriter().info("TEST - Closing durable client for the first time");
    // Stop the durable client
    closeCache(true);

    LogWriterUtils.getLogWriter().info("TEST - Durable client closed for the first time");

    // Wait for server to cleanup client resources
    // temporary fix for bug 38345.
    Wait.pause(2000);

    LogWriterUtils.getLogWriter().info("TEST - Creating the durable client with one fewer servers");
    // We recreate the durable client, but this
    // Time we won't have it create any queues
    createCacheClient(2, 20, false);

    HashSet redundantServers2 = new HashSet(pool.getRedundantNames());
    redundantServers2.add(pool.getPrimaryName());
    LogWriterUtils.getLogWriter()
        .info("TEST - Durable client created again, now with servers " + redundantServers2);
    Host host = Host.getHost(0);
    // Make sure we create client to server connections to all of the servers
    pool.acquireConnection(
        new ServerLocation(NetworkUtils.getServerHostName(host), PORT1));
    pool.acquireConnection(
        new ServerLocation(NetworkUtils.getServerHostName(host), PORT2));
    pool.acquireConnection(
        new ServerLocation(NetworkUtils.getServerHostName(host), PORT3));
    pool.acquireConnection(
        new ServerLocation(NetworkUtils.getServerHostName(host), PORT4));

    LogWriterUtils.getLogWriter().info("TEST - All pool connections are now aquired");

    closeCache(true);

    LogWriterUtils.getLogWriter().info("TEST - closed durable client for the second time");

    // Wait for server to cleanup client resources
    // temporary fix for bug 38345.
    Wait.pause(2000);

    LogWriterUtils.getLogWriter().info("TEST - creating durable client for the third time");
    // Now we should connect to all of the servers we were originally connected to
    createCacheClient(2, 20);

    HashSet redundantServersAfterReconnect = new HashSet(pool.getRedundantNames());
    redundantServersAfterReconnect.add(pool.getPrimaryName());

    LogWriterUtils.getLogWriter()
        .info("TEST - durable client created for the third time, now with servers "
            + redundantServersAfterReconnect);

    instance.determineAndVerfiyRedundantServers(redundantServersAfterReconnect);
    instance.determineAndVerfiyNonRedundantServers(redundantServersAfterReconnect);

    assertEquals(redundantServers, redundantServersAfterReconnect);

    // Now we wait to make sure the durable client expiration task isn't fired.
    Wait.pause(25000);

    LogWriterUtils.getLogWriter()
        .info("TEST - Finished waiting for durable client expiration task");

    redundantServersAfterReconnect = new HashSet(pool.getRedundantNames());
    redundantServersAfterReconnect.add(pool.getPrimaryName());

    instance.determineAndVerfiyRedundantServers(redundantServersAfterReconnect);
    instance.determineAndVerfiyNonRedundantServers(redundantServersAfterReconnect);

    assertEquals(redundantServers, redundantServersAfterReconnect);
  }
This test checks a problem found in bug 39332 1. Durable client disconnects 2. Durable client
comes back, creates a create to server connection but not a queue connection 3. Durable client
disconnects again 4. Durable client connects 5. Eventually, all of the durable clients
connections are closed because the durable expiration timer task created in step 1 is never
cancelled.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientReconnectDUnitTest.java