Uploaded image for project: 'Hibernate Search'
  1. HSEARCH-492

FSMasterDirectoryProvider and FSSlaveDirectoryProvider don't shutdown the Executor

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.1.GA
    • Fix Version/s: 3.2.0.CR1
    • Component/s: directory provider
    • Labels:
      None
    • Environment:
      Java 1.6.0
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

      Description

      I'm using Hibernate Search clustering feature in a stand alone Java application (not a webapp).
      My problem is the application never stops: many threads are still living.

      Both FSMasterDirectoryProvider and FSSlaveDirectoryProvider use a Single Thread Executor to perform the CopyTask.
      When the FSSlaveDirectoryProvider.stop() is called, the timer is stopped, but not the Executor in the TimerTask.
      Consequence is the process can't stop, because some threads are still living, endlessly.

      This happens after the first CopyDirectory task was executed.

      My fix was to copy this class in my code, and replace the Executor in TriggerTask class by an ExecutorService in FSSlaveDirectoryProvider class.
      The ExecutorService is initialized in the start() method:

      this.executor = Executors.newSingleThreadExecutor() ;

      And properly shut down in the stop() method:

      executor.shutdown();
      boolean terminated = false ;
      try{
        terminated = executor.awaitTermination(20, TimeUnit.SECONDS);
      } catch (InterruptedException e1) {
        terminated = false ;
      }
      if (!terminated) {
        executor.shutdownNow() ;
      }
      

        Attachments

          Activity

            People

            • Assignee:
              sanne Sanne Grinovero
              Reporter:
              scharton Sylvain Charton
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: