JDK-8250772 : Test com/sun/jndi/ldap/NamingExceptionMessageTest.java fails intermittently with javax.naming.ServiceUnavailableException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.naming
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-07-29
  • Updated: 2025-06-09
  • Resolved: 2020-08-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 16 JDK 7 JDK 8
11.0.10-oracleFixed 16 b11Fixed 7u481Fixed 8u331Fixed
Related Reports
Relates :  
Description
It looks like the test fails intermittently due to a race condition which changes the point where the exception that is relayed to the caller is thrown. To be evaluated.

System.err

java.net.SocketException: Socket closed
at java.base/sun.nio.ch.NioSocketImpl.ensureOpenAndConnected(NioSocketImpl.java:165)
at java.base/sun.nio.ch.NioSocketImpl.beginRead(NioSocketImpl.java:231)
at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:299)
at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:350)
at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:803)
at java.base/java.net.Socket$SocketInputStream.read(Socket.java:981)
at java.base/java.io.InputStream.read(InputStream.java:218)
at BaseLdapServer.handleConnection(BaseLdapServer.java:142)
at BaseLdapServer.lambda$acceptConnections$0(BaseLdapServer.java:99)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
java.lang.Exception: failures: 1
at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:96)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:298)
at java.base/java.lang.Thread.run(Thread.java:832)

JavaTest Message: Test threw exception: java.lang.Exception
JavaTest Message: shutting down test

System.out

[TestNG] Running:
  com/sun/jndi/ldap/NamingExceptionMessageTest.java

Got naming exception:javax.naming.ServiceUnavailableException: 127.0.0.1:51455; socket closed
test NamingExceptionMessageTest.connectionClosureMessageTest(): failure
java.lang.AssertionError: expected [LDAP connection has been closed] but found [127.0.0.1:51455; socket closed]
at org.testng.Assert.fail(Assert.java:94)
at org.testng.Assert.failNotEquals(Assert.java:496)
at org.testng.Assert.assertEquals(Assert.java:125)
at org.testng.Assert.assertEquals(Assert.java:178)
at org.testng.Assert.assertEquals(Assert.java:188)
at NamingExceptionMessageTest.connectionClosureMessageTest(NamingExceptionMessageTest.java:71)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:773)
at org.testng.TestRunner.run(TestRunner.java:623)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java:1018)
at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:94)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:298)
at java.base/java.lang.Thread.run(Thread.java:832)
Got naming exception:javax.naming.NamingException: LDAP response read timed out, timeout used: 129 ms.
test NamingExceptionMessageTest.timeoutMessageTest(): success


Comments
Fix request (11u) -- will label after testing completed. I would like to downport this for parity with 11.0.10-oracle. Applies clean.
23-10-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/63b1fe3160fd User: aefimov Date: 2020-08-12 10:47:15 +0000
12-08-2020

The hypothesis of the test failure root-cause could be confirmed by adding delay between sending the bind request and reading the reply to LdapClient code: --- a/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java +++ b/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java ber.reset(); // clear internally-stored password } + try { + Thread.sleep(1_000); + } catch (InterruptedException e) { + } + // Read reply BerDecoder rber = conn.readReply(req); With such modifications test fails with ServiceUnavailableException every time it's run.
31-07-2020

The test fails intermittently due to it's concurrent nature: Sometimes test server could close the connection before the LDAP client starts up the read-out of the reply message. The solution could be to update the test code: a) Add timeout before closing the connection in BIND operation handler b) Treat ServiceUnavailableException as acceptable exceptions
31-07-2020