Force a server call to update the LDAP context

With the fix #430 the `DefaultTlsDirContextAuthenticationStrategy` was
extended by the call of `ctx.reconnect(null);`. Due to the Java bug
JDK-8217606 this call creates a second connection while the first
connection remains open forever.

fixes #502
see JDK-8217606 https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8217606
This commit is contained in:
Michael Schneider
2019-02-08 13:24:45 +01:00
committed by Rob Winch
parent 15142d4ae1
commit 8b68cb0c3c
2 changed files with 5 additions and 5 deletions

View File

@@ -36,8 +36,8 @@ public class DefaultTlsDirContextAuthenticationStrategy extends AbstractTlsDirCo
ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION, SIMPLE_AUTHENTICATION);
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDn);
ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, password);
// Force reconnect with user credentials
ctx.reconnect(null);
// Force a server call as we have updated the environment (gh-430, gh-502)
ctx.lookup("");
}
}

View File

@@ -21,11 +21,11 @@ public class DefaultTlsDirContextAuthenticationStrategyTests {
private DefaultTlsDirContextAuthenticationStrategy strategy = new DefaultTlsDirContextAuthenticationStrategy();
// gh-430
// gh-430, gh-502
@Test
public void applyAuthenticationThenReconnectInvoked() throws Exception {
public void applyAuthenticationThenLookupInvoked() throws Exception {
this.strategy.applyAuthentication(this.context, "username", "password");
verify(this.context).reconnect(null);
verify(this.context).lookup("");
}
}