Skip to content

Commit 0a1d3f5

Browse files
Ihor Herasymenkojzheaux
authored andcommitted
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
1 parent a377898 commit 0a1d3f5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@
7474
*/
7575
public abstract class AbstractContextSource implements BaseLdapPathContextSource, InitializingBean {
7676

77-
private static final Class<com.sun.jndi.ldap.LdapCtxFactory> DEFAULT_CONTEXT_FACTORY
78-
= com.sun.jndi.ldap.LdapCtxFactory.class;
77+
private static final String DEFAULT_CONTEXT_FACTORY = "com.sun.jndi.ldap.LdapCtxFactory";
7978

8079
private static final Class<DefaultDirObjectFactory> DEFAULT_DIR_OBJECT_FACTORY = DefaultDirObjectFactory.class;
8180
private static final boolean DONT_DISABLE_POOLING = false;
@@ -84,7 +83,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
8483

8584
private Class<?> dirObjectFactory = DEFAULT_DIR_OBJECT_FACTORY;
8685

87-
private Class<?> contextFactory = DEFAULT_CONTEXT_FACTORY;
86+
private Class<?> contextFactory;
8887

8988
private LdapName base = LdapUtils.emptyLdapName();
9089

@@ -439,7 +438,7 @@ private Hashtable<String, Object> setupAnonymousEnv() {
439438

440439
Hashtable<String, Object> env = new Hashtable<String, Object>(baseEnv);
441440

442-
env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory.getName());
441+
env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory != null ? contextFactory.getName() : DEFAULT_CONTEXT_FACTORY);
443442
env.put(Context.PROVIDER_URL, assembleProviderUrlString(urls));
444443

445444
if (dirObjectFactory != null) {

0 commit comments

Comments
 (0)