camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [camel] branch camel-2.20.x updated: Close file watcher when stopping.
Date Tue, 05 Jun 2018 12:11:16 GMT
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.20.x by this push:
     new 7e7c6ea  Close file watcher when stopping.
7e7c6ea is described below

commit 7e7c6ea30281106ca1b1e3dcd006988f2a192ea4
Author: Claus Ibsen <claus.ibsen@gmail.com>
AuthorDate: Tue Jun 5 14:09:39 2018 +0200

    Close file watcher when stopping.
---
 .../main/java/org/apache/camel/impl/FileWatcherReloadStrategy.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/camel-core/src/main/java/org/apache/camel/impl/FileWatcherReloadStrategy.java
b/camel-core/src/main/java/org/apache/camel/impl/FileWatcherReloadStrategy.java
index b908054..4b23d5f 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/FileWatcherReloadStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/FileWatcherReloadStrategy.java
@@ -56,6 +56,7 @@ public class FileWatcherReloadStrategy extends ReloadStrategySupport {
 
     private String folder;
     private boolean isRecursive;
+    private WatchService watcher;
     private ExecutorService executorService;
     private WatchFileChangesTask task;
     private Map<WatchKey, Path> folderKeys;
@@ -143,7 +144,7 @@ public class FileWatcherReloadStrategy extends ReloadStrategySupport {
 
             try {
                 Path path = dir.toPath();
-                WatchService watcher = path.getFileSystem().newWatchService();
+                watcher = path.getFileSystem().newWatchService();
                 // we cannot support deleting files as we don't know which routes that would
be
                 if (isRecursive) {
                     this.folderKeys = new HashMap<WatchKey, Path>();
@@ -191,6 +192,10 @@ public class FileWatcherReloadStrategy extends ReloadStrategySupport
{
             getCamelContext().getExecutorServiceManager().shutdownGraceful(executorService);
             executorService = null;
         }
+
+        if (watcher != null) {
+            IOHelper.close(watcher);
+        }
     }
 
     /**

-- 
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.

Mime
View raw message