From 8b68cb0c3cf4d0471e34a19379f92a53f39ee573 Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Fri, 8 Feb 2019 13:24:45 +0100 Subject: [PATCH] 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 --- .../support/DefaultTlsDirContextAuthenticationStrategy.java | 4 ++-- .../DefaultTlsDirContextAuthenticationStrategyTests.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategy.java b/core/src/main/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategy.java index 651ee981..354a0ae7 100755 --- a/core/src/main/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategy.java +++ b/core/src/main/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategy.java @@ -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(""); } } diff --git a/core/src/test/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategyTests.java b/core/src/test/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategyTests.java index 9b7cdced..cd350b33 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategyTests.java +++ b/core/src/test/java/org/springframework/ldap/core/support/DefaultTlsDirContextAuthenticationStrategyTests.java @@ -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(""); } } \ No newline at end of file