--- old/src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java 2020-03-18 14:43:55.000000000 +0800 +++ new/src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java 2020-03-18 14:43:55.000000000 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -250,7 +250,12 @@ if (debug) { System.err.println("EventSupport.removeDeadNotifier: " + info.name); } - notifiers.remove(info); + if (notifiers != null) { + // Only do this if cleanup() not been triggered, otherwise here + // will throw NullPointerException since notifiers will be set to + // null in cleanup() + notifiers.remove(info); + } } /** @@ -329,6 +334,11 @@ */ synchronized void queueEvent(EventObject event, Vector vector) { + if (notifiers == null) { + // That means cleanup() already done, not queue event anymore, + // otherwise, new created EventQueue will not been cleanup. + return; + } if (eventQueue == null) eventQueue = new EventQueue();