BaseClient thread leak on disconnect

You are here

BaseClient thread leak on disconnect

2 posts / 0 new
Last post
fabiengb
fabiengb's picture
BaseClient thread leak on disconnect

Hi,

I am currently customizing mendelson AS2 (v1.1 b49) for internal use, and i discovered a thread leak in de.mendelson.util.clientserver.BaseClient class.

When calling disconnect method, a thread created during in connection step resides in memory.

Problem is coming from this line in connect method:

this.connector.getFilterChain().addLast("executor", new ExecutorFilter(new UnorderedThreadPoolExecutor()));

Instantiated ExecutorFilter & UnorderedThreadPoolExecutor objects are not recorded in memory and are not shut down when disconnecting.

I replaced this line by:

unorderedThreadPoolExecutor = new UnorderedThreadPoolExecutor();
executorFilter = new ExecutorFilter(unorderedThreadPoolExecutor);
this.connector.getFilterChain().addLast("executor", executorFilter);

unorderedThreadPoolExecutor & executorFilter being private class members.
And then, added this code to disconnect method:

unorderedThreadPoolExecutor.shutdownNow();
executorFilter.destroy();

this.connector.dispose(true);

After this fix, no unwanted thread resides in memory after disconnect.

Fab

service
service's picture

fabiengb,

thanks for the feedback, we will change this in the code for the next version. Anyway this should be no problem in production use as the BaseClient is used for the client-server interface only and the JVM shuts down after a disconnect.

Regards