mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trustin Lee (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (DIRMINA-523) Default thread model should be created laziliy
Date Wed, 20 Feb 2008 03:34:46 GMT

     [ https://issues.apache.org/jira/browse/DIRMINA-523?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Trustin Lee resolved DIRMINA-523.
---------------------------------

    Resolution: Fixed
      Assignee: Trustin Lee

Patch applied after some sanitization.  HTH.

> 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.0.8, 1.1.5, 1.0.9, 1.1.6
>            Reporter: Kristjan Habicht
>            Assignee: Trustin Lee
>            Priority: Minor
>             Fix For: 1.0.10, 1.1.7
>
>
> 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.


Mime
View raw message