Pil0tXia commented on code in PR #4716:
URL: https://github.com/apache/eventmesh/pull/4716#discussion_r1446345311
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/file/WatchFileTask.java:
##########
@@ -55,11 +56,21 @@ public WatchFileTask(String directoryPath) {
throw new IllegalArgumentException("must be a file directory : " +
directoryPath);
}
- try (WatchService watchService = FILE_SYSTEM.newWatchService()) {
- this.watchService = watchService;
+ try {
+ this.watchService = FILE_SYSTEM.newWatchService();
+ } catch (IOException ex) {
+ throw new RuntimeException("WatchService initialization fail", ex);
+ }
+
+ try {
path.register(this.watchService, StandardWatchEventKinds.OVERFLOW,
StandardWatchEventKinds.ENTRY_MODIFY,
StandardWatchEventKinds.ENTRY_CREATE,
StandardWatchEventKinds.ENTRY_DELETE);
- } catch (Exception ex) {
+ } catch (IOException ex) {
+ try {
+ this.watchService.close();
Review Comment:
Please see my latest
https://github.com/apache/eventmesh/pull/4716#pullrequestreview-1811550992
--
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]