OpenJDK / jdk / jdk
changeset 58466:b96911696f71
8241130: com.sun.jndi.ldap.EventSupport.removeDeadNotifier: java.lang.NullPointerException
Reviewed-by: dfuchs
author | xyin |
---|---|
date | Fri, 20 Mar 2020 10:24:46 +0800 |
parents | 0c03ed579379 |
children | eadd3a62ea18 |
files | src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java test/jdk/com/sun/jndi/ldap/RemoveNamingListenerTest.java |
diffstat | 2 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java Fri Mar 20 00:32:29 2020 +0000 +++ b/src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java Fri Mar 20 10:24:46 2020 +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<? extends NamingListener> 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();
--- a/test/jdk/com/sun/jndi/ldap/RemoveNamingListenerTest.java Fri Mar 20 00:32:29 2020 +0000 +++ b/test/jdk/com/sun/jndi/ldap/RemoveNamingListenerTest.java Fri Mar 20 10:24:46 2020 +0800 @@ -39,7 +39,7 @@ /** * @test - * @bug 8176192 + * @bug 8176192 8241130 * @summary Incorrect usage of Iterator in Java 8 In com.sun.jndi.ldap. * EventSupport.removeNamingListener * @modules java.naming