Default thread model should be created laziliy
----------------------------------------------
Key: DIRMINA-523
URL: https://issues.apache.org/jira/browse/DIRMINA-523
Project: MINA
Issue Type: Improvement
Components: Core
Affects Versions: 1.1.5
Reporter: Kristjan Habicht
Currently when BaseIoServiceConfig is created then also ExecutorThreadModel is
created. This creates additional 16 threads which will not be shut down even if
ThreadModel.MANUAL is used.
Here is a patch which will fix this problem by creating the ExecutorThreadModel
lazily if the ThreadModel is not set.
Index: BaseIoServiceConfig.java
===================================================================
--- BaseIoServiceConfig.java (revision 616503)
+++ BaseIoServiceConfig.java (working copy)
@@ -40,20 +40,14 @@
private IoFilterChainBuilder filterChainBuilder = new
DefaultIoFilterChainBuilder();
/**
- * The default thread model.
- */
- private final ThreadModel defaultThreadModel = ExecutorThreadModel
- .getInstance("AnonymousIoService");
-
- /**
* Current thread model.
*/
- private ThreadModel threadModel = defaultThreadModel;
+ private ThreadModel threadModel;
public BaseIoServiceConfig() {
super();
}
-
+
public IoFilterChainBuilder getFilterChainBuilder() {
return filterChainBuilder;
}
@@ -75,15 +69,15 @@
}
public ThreadModel getThreadModel() {
- return threadModel;
+ if (threadModel == null) {
+ // if thread model hasn't been set return the default one
+ return getDefaultThreadModel();
+ } else {
+ return threadModel;
+ }
}
public void setThreadModel(ThreadModel threadModel) {
- if (threadModel == null) {
- // We reuse the previous default model to prevent too much
- // daemon threads are created.
- threadModel = defaultThreadModel;
- }
this.threadModel = threadModel;
}
@@ -110,4 +104,11 @@
return ret;
}
+
+ /**
+ * @return The default thread model.
+ */
+ private static ThreadModel getDefaultThreadModel() {
+ return ExecutorThreadModel.getInstance("AnonymousIoService");
+ }
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.