Fix ISE during WatchService disposal (#3432)

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
pull/3436/head
jimtng 2023-03-08 00:43:45 +10:00 committed by GitHub
parent 6d989ea6e2
commit f9751448c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -162,8 +162,12 @@ public class WatchServiceImpl implements WatchService, DirectoryChangeListener {
}
ServiceRegistration<?> localReg = this.reg;
if (localReg != null && bundleContext.getService(localReg.getReference()) != null) {
localReg.unregister();
if (localReg != null) {
try {
localReg.unregister();
} catch (IllegalStateException e) {
logger.debug("WatchService '{}' was already unregistered.", name, e);
}
this.reg = null;
}
}