From e33cec202fee549a07071d2472b26bc4806908d9 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Tue, 30 Dec 2008 10:42:45 +0800 Subject: [PATCH] 6717680: LdapCtx does not close the connection if initialization fails Reviewed-by: vinnie, xuelei --- jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java index bec6fd0e761..5f9462c5931 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java @@ -302,7 +302,16 @@ final public class LdapCtx extends ComponentDirContext schemaTrees = new Hashtable(11, 0.75f); initEnv(); - connect(false); + try { + connect(false); + } catch (NamingException e) { + try { + close(); + } catch (Exception e2) { + // Nothing + } + throw e; + } } LdapCtx(LdapCtx existing, String newDN) throws NamingException {