6717680: LdapCtx does not close the connection if initialization fails
Reviewed-by: vinnie, xuelei
--- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java Wed Dec 24 15:48:59 2008 -0800
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java Tue Dec 30 10:42:45 2008 +0800
@@ -302,7 +302,16 @@
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 {