From 4e9bfcbd9375778cb7cf99ad8f6f207c03142079 Mon Sep 17 00:00:00 2001 From: robm Date: Mon, 2 Jul 2012 19:32:35 +0100 Subject: [PATCH] 7174887: Deadlock in jndi ldap connection cleanup Reviewed-by: xuelei --- .../classes/com/sun/jndi/ldap/Connection.java | 6 ++++-- .../classes/com/sun/jndi/ldap/LdapClient.java | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/share/classes/com/sun/jndi/ldap/Connection.java b/src/share/classes/com/sun/jndi/ldap/Connection.java index 464e3d1bf..2b8b410f4 100644 --- a/src/share/classes/com/sun/jndi/ldap/Connection.java +++ b/src/share/classes/com/sun/jndi/ldap/Connection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2012, 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 @@ -680,9 +680,11 @@ public final class Connection implements Runnable { ldr = ldr.next; } } - parent.processConnectionClosure(); } } + if (nparent) { + parent.processConnectionClosure(); + } } diff --git a/src/share/classes/com/sun/jndi/ldap/LdapClient.java b/src/share/classes/com/sun/jndi/ldap/LdapClient.java index 0053758c2..788152929 100644 --- a/src/share/classes/com/sun/jndi/ldap/LdapClient.java +++ b/src/share/classes/com/sun/jndi/ldap/LdapClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2012, 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 @@ -488,14 +488,16 @@ public final class LdapClient implements PooledConnection { */ void processConnectionClosure() { // Notify listeners - if (unsolicited.size() > 0) { - String msg; - if (conn != null) { - msg = conn.host + ":" + conn.port + " connection closed"; - } else { - msg = "Connection closed"; + synchronized (unsolicited) { + if (unsolicited.size() > 0) { + String msg; + if (conn != null) { + msg = conn.host + ":" + conn.port + " connection closed"; + } else { + msg = "Connection closed"; + } + notifyUnsolicited(new CommunicationException(msg)); } - notifyUnsolicited(new CommunicationException(msg)); } // Remove from pool -- GitLab