Pil0tXia commented on code in PR #4716:
URL: https://github.com/apache/eventmesh/pull/4716#discussion_r1446331535


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileTask.java:
##########
@@ -83,6 +78,11 @@ public void addFileChangeListener(FileChangeListener 
fileChangeListener) {
 
     public void shutdown() {
         watch = false;
+        try {
+            this.watchService.close();
+        } catch (IOException e) {
+            throw new RuntimeException("Unable to close WatchService", e);
+        }

Review Comment:
   In your latest commit, you added the shutdown handling for the 
`watchService` in the `WatchFileTask#shutdown()` method. However, this doesn't 
actually change anything because the `shutdown()` method is only called before 
the application is closed. Nevertheless, I think the added code can still be 
kept.



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileTask.java:
##########
@@ -66,11 +66,6 @@ public WatchFileTask(String directoryPath) {
             path.register(this.watchService, StandardWatchEventKinds.OVERFLOW, 
StandardWatchEventKinds.ENTRY_MODIFY,
                 StandardWatchEventKinds.ENTRY_CREATE, 
StandardWatchEventKinds.ENTRY_DELETE);
         } catch (IOException ex) {
-            try {
-                this.watchService.close();
-            } catch (IOException e) {
-                ex.addSuppressed(e);
-            }

Review Comment:
   However, you removed the part where the `watchService` is closed in the 
exception handling, and I think that this part should be retained.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to