Fix NPE in WatchServiceImpl (#3633)

It was reported on the forum that in some cases the hash is null.

Signed-off-by: Jan N. Klug <github@klug.nrw>
This commit is contained in:
J-N-K 2023-05-27 19:19:25 +02:00 committed by GitHub
parent c6a4dd2a31
commit ee6d7b39b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -223,6 +223,12 @@ public class WatchServiceImpl implements WatchService, DirectoryChangeListener {
Path path = directoryChangeEvent.path();
if (directoryChangeEvent.eventType() != DirectoryChangeEvent.EventType.DELETE
&& directoryChangeEvent.hash() == null) {
logger.warn("Detected invalid event (hash must not be null for CREATE/MODIFY): {}", directoryChangeEvent);
return;
}
synchronized (scheduledEvents) {
ScheduledFuture<?> future = scheduledEvents.remove(path);
if (future != null && !future.isDone()) {