File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
spring-integration-file/src/main/java/org/springframework/integration/file Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 28
28
import java .nio .file .WatchKey ;
29
29
import java .nio .file .WatchService ;
30
30
import java .nio .file .attribute .BasicFileAttributes ;
31
+ import java .util .Arrays ;
31
32
import java .util .Collection ;
32
33
import java .util .Comparator ;
33
34
import java .util .LinkedHashSet ;
@@ -278,7 +279,10 @@ public void setUseWatchService(boolean useWatchService) {
278
279
*/
279
280
public void setWatchEvents (WatchEventType ... watchEvents ) {
280
281
Assert .notEmpty (watchEvents , "'watchEvents' must not be empty." );
281
- this .watchEvents = watchEvents ;
282
+ Assert .noNullElements (watchEvents , "'watchEvents' must not contain null elements." );
283
+ Assert .state (!this .running , "Cannot change watch events while running." );
284
+
285
+ this .watchEvents = Arrays .copyOf (watchEvents , watchEvents .length );
282
286
}
283
287
284
288
@ Override
@@ -495,12 +499,14 @@ private Set<File> filesFromEvents() {
495
499
files .remove (file );
496
500
}
497
501
else {
498
- if (file .isDirectory ()) {
499
- files .addAll (walkDirectory (file .toPath ()));
500
- }
501
- else {
502
- files .remove (file );
503
- files .add (file );
502
+ if (file .exists ()) {
503
+ if (file .isDirectory ()) {
504
+ files .addAll (walkDirectory (file .toPath ()));
505
+ }
506
+ else {
507
+ files .remove (file );
508
+ files .add (file );
509
+ }
504
510
}
505
511
}
506
512
}
You can’t perform that action at this time.
0 commit comments