test/jdk/com/sun/jndi/ldap/DisconnectNPETest.java
author xyin
Wed, 01 May 2019 00:06:22 -0700
branchJDK-8210696-branch
changeset 57345 ff884a2f247b
parent 51760 caac55d48dc3
permissions -rw-r--r--
JDK-8210696-branch: push initial fix change
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51760
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
     1
/*
57345
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
51760
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
     4
 *
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
     8
 *
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    13
 * accompanied this code).
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    14
 *
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    18
 *
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    21
 * questions.
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    22
 */
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    23
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    24
import javax.naming.Context;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    25
import javax.naming.NamingException;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    26
import javax.naming.directory.DirContext;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    27
import javax.naming.directory.InitialDirContext;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    28
import java.io.IOException;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    29
import java.net.InetAddress;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    30
import java.net.ServerSocket;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    31
import java.util.Hashtable;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    32
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    33
/*
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    34
 * @test
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    35
 * @bug 8205330
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    36
 * @summary Test that If a connection has already been established and then
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    37
 *          the LDAP directory server sends an (unsolicited)
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    38
 *          "Notice of Disconnection", make sure client handle it correctly,
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    39
 *          no NPE been thrown.
57345
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    40
 * @library lib/
51760
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    41
 * @run main/othervm DisconnectNPETest
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    42
 */
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    43
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    44
public class DisconnectNPETest {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    45
    // Normally the NPE bug should be hit less than 100 times run, but just in
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    46
    // case, we set repeat count to 1000 here.
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    47
    private static final int REPEAT_COUNT = 1000;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    48
57345
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    49
    // "Notice of Disconnection" message
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    50
    private static final byte[] DISCONNECT_MSG = { 0x30, 0x4C, 0x02, 0x01, 0x00,
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    51
            0x78, 0x47, 0x0A, 0x01, 0x34, 0x04, 0x00, 0x04, 0x28, 0x55, 0x4E,
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    52
            0x41, 0x56, 0x41, 0x49, 0x4C, 0x41, 0x42, 0x4C, 0x45, 0x3A, 0x20,
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    53
            0x54, 0x68, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20,
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    54
            0x77, 0x69, 0x6C, 0x6C, 0x20, 0x64, 0x69, 0x73, 0x63, 0x6F, 0x6E,
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    55
            0x6E, 0x65, 0x63, 0x74, 0x21, (byte) 0x8A, 0x16, 0x31, 0x2E, 0x33,
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    56
            0x2E, 0x36, 0x2E, 0x31, 0x2E, 0x34, 0x2E, 0x31, 0x2E, 0x31, 0x34,
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    57
            0x36, 0x36, 0x2E, 0x32, 0x30, 0x30, 0x33, 0x36 };
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    58
    private static final byte[] BIND_RESPONSE = { 0x30, 0x0C, 0x02, 0x01, 0x01,
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    59
            0x61, 0x07, 0x0A, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00 };
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    60
51760
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    61
    public static void main(String[] args) throws IOException {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    62
        new DisconnectNPETest().run();
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    63
    }
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    64
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    65
    private ServerSocket serverSocket;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    66
    private Hashtable<Object, Object> env;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    67
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    68
    private void initRes() throws IOException {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    69
        serverSocket = new ServerSocket(0, 0, InetAddress.getLoopbackAddress());
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    70
    }
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    71
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    72
    private void initTest() {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    73
        env = new Hashtable<>();
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    74
        env.put(Context.INITIAL_CONTEXT_FACTORY,
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    75
                "com.sun.jndi.ldap.LdapCtxFactory");
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    76
        env.put(Context.PROVIDER_URL, String.format("ldap://%s:%d/",
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    77
                InetAddress.getLoopbackAddress().getHostName(),
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    78
                serverSocket.getLocalPort()));
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    79
        env.put(Context.SECURITY_AUTHENTICATION, "simple");
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    80
        env.put(Context.SECURITY_PRINCIPAL,
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    81
                "cn=8205330,ou=Client6,ou=Vendor1,o=IMC,c=US");
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    82
        env.put(Context.SECURITY_CREDENTIALS, "secret123");
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    83
    }
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    84
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    85
    private void run() throws IOException {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    86
        initRes();
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    87
        initTest();
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    88
        int count = 0;
57345
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    89
        try (BaseLdapServer ignored = new BaseLdapServer(serverSocket)
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    90
                .setCommonRequestHandler((msg, out) -> {
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    91
                    if (msg.getOperation()
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    92
                            == LdapMessage.Operation.BIND_REQUEST) {
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    93
                        out.write(BIND_RESPONSE);
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    94
                        out.write(DISCONNECT_MSG);
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    95
                    }
ff884a2f247b JDK-8210696-branch: push initial fix change
xyin
parents: 51760
diff changeset
    96
                }).startServer()) {
51760
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    97
            while (count < REPEAT_COUNT) {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    98
                count++;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
    99
                InitialDirContext context = null;
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   100
                try {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   101
                    context = new InitialDirContext(env);
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   102
                } catch (NamingException ne) {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   103
                    System.out.println("(" + count + "/" + REPEAT_COUNT
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   104
                            + ") It's ok to get NamingException: " + ne);
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   105
                    // for debug
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   106
                    ne.printStackTrace(System.out);
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   107
                } finally {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   108
                    cleanupContext(context);
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   109
                }
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   110
            }
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   111
        } finally {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   112
            System.out.println("Test count: " + count + "/" + REPEAT_COUNT);
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   113
        }
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   114
    }
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   115
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   116
    private void cleanupContext(DirContext context) {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   117
        if (context != null) {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   118
            try {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   119
                context.close();
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   120
            } catch (NamingException e) {
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   121
                // ignore
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   122
            }
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   123
        }
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   124
    }
caac55d48dc3 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection
xyin
parents:
diff changeset
   125
}