Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-523

Default thread model should be created laziliy

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0.8, 1.1.5, 1.0.9, 1.1.6
    • 1.0.10, 1.1.7
    • Core
    • None

    Description

      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"); + }

      }

      Attachments

        Activity

          People

            trustin Trustin Lee
            kristjan Kristjan Habicht
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: