From 0a1d3f595b670412b7fd7ab739237c57381a7fa8 Mon Sep 17 00:00:00 2001 From: Ihor Herasymenko Date: Thu, 4 Feb 2021 00:08:15 -0500 Subject: [PATCH] Remove a compile time reference to com.sun.jndi.ldap.LdapCtxFactory com.sun.jndi.ldap.LdapCtxFactory is not supposed to be used by anyone but the 'java.naming' module in post Java 8 world. Fixes #543 --- .../ldap/core/support/AbstractContextSource.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java b/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java index 86a629be..18db3a20 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java +++ b/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java @@ -74,8 +74,7 @@ import java.util.Map; */ public abstract class AbstractContextSource implements BaseLdapPathContextSource, InitializingBean { - private static final Class DEFAULT_CONTEXT_FACTORY - = com.sun.jndi.ldap.LdapCtxFactory.class; + private static final String DEFAULT_CONTEXT_FACTORY = "com.sun.jndi.ldap.LdapCtxFactory"; private static final Class DEFAULT_DIR_OBJECT_FACTORY = DefaultDirObjectFactory.class; private static final boolean DONT_DISABLE_POOLING = false; @@ -84,7 +83,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource private Class dirObjectFactory = DEFAULT_DIR_OBJECT_FACTORY; - private Class contextFactory = DEFAULT_CONTEXT_FACTORY; + private Class contextFactory; private LdapName base = LdapUtils.emptyLdapName(); @@ -439,7 +438,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource Hashtable env = new Hashtable(baseEnv); - env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory.getName()); + env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory != null ? contextFactory.getName() : DEFAULT_CONTEXT_FACTORY); env.put(Context.PROVIDER_URL, assembleProviderUrlString(urls)); if (dirObjectFactory != null) {