RFR: 8313657 : com.sun.jndi.ldap.Connection.cleanup does not close connections on SocketTimeoutErrors [v3]
Mark Sheppard
msheppar at openjdk.org
Mon Aug 7 09:55:31 UTC 2023
On Fri, 4 Aug 2023 19:09:58 GMT, Weibing Xiao <duke at openjdk.org> wrote:
>> com.sun.jndi.ldap.Connection::leanup does not close the underlying socket if the is an IOException generation when the output stream was flushing the buffer.
>>
>> Please refer to the bug https://bugs.openjdk.org/browse/JDK-8313657.
>
> Weibing Xiao has updated the pull request incrementally with one additional commit since the last revision:
>
> update error message
I ran the test multiple times in mach5 and it executes fine. However, while examining the log output I noticed the "The socket was not closed. " output. This is a little confusing. While looking at the test and exploring the origins of this outout, we see that the test is essentially an othervm execution. As such, I restructured the test to othervm and it executes with some informative output and eliminates the discombobulating output.
I have left a comment in the JBS bug item with some further details and changes for othervm. This gives some imformative output as the test executes.
The origins of the output is the main try block executing in the agentvm and the throwing of a ClassNotFoundException.
If you don't wish to do otherrvm and to avoid the "The socket was not closed. " output, and if wish to retain the same structure, then consider adding a run command to the test with an arg, and then a conditional on the core test logic e.g.
* @run main SocketCloseTest launcher
and in the main method
public static void main(String[] args) throws Exception {
Hashtable<String, Object> props = new Hashtable<>();
if (args.length == 0) { // only executed in the launched JVM
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
props.put(Context.PROVIDER_URL, "ldap://localhost:1389/o=example");
props.put("java.naming.ldap.factory.socket", CustomSocketFactory.class.getName());
try {
final DirContext ctx = new InitialDirContext(props);
} catch (Exception e) {
if (CustomSocketFactory.customSocket.closeMethodCalledCount() > 0) {
System.out.println(SOCKET_CLOSED_MSG);
} else {
System.out.println(SOCKET_NOT_CLOSED_MSG);
}
}
}
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm("SocketCloseTest_II");
outputAnalyzer.stdoutShouldContain(SOCKET_CLOSED_MSG);
outputAnalyzer.stdoutShouldNotContain(SOCKET_NOT_CLOSED_MSG);
outputAnalyzer.stdoutShouldContain(BAD_FLUSH);
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15143#issuecomment-1667550730
More information about the core-libs-dev
mailing list