Fix IllegalStateException in WatchServiceImpl (#3389)

Added a check to prevent attempts to unregister already unregistered service

Signed-off-by: Jan N. Klug <github@klug.nrw>
This commit is contained in:
J-N-K 2023-03-05 09:44:58 +01:00 committed by GitHub
parent 07e8ff56c7
commit 278e99b461
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -162,7 +162,7 @@ public class WatchServiceImpl implements WatchService, DirectoryChangeListener {
} }
ServiceRegistration<?> localReg = this.reg; ServiceRegistration<?> localReg = this.reg;
if (localReg != null) { if (localReg != null && bundleContext.getService(localReg.getReference()) != null) {
localReg.unregister(); localReg.unregister();
this.reg = null; this.reg = null;
} }