rishabhdaim commented on code in PR #2721:
URL: https://github.com/apache/jackrabbit-oak/pull/2721#discussion_r2813306775
##########
oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java:
##########
@@ -460,9 +464,15 @@ public synchronized boolean stopAndWait(int timeOut,
TimeUnit unit) {
*/
public synchronized void stop() {
Validate.checkState(registration != null, "Change processor not
started");
- if (running.stop()) {
- registration.unregister();
- runningMonitor.leave();
+
+ if (stopFlagSet()) {
+ // Wait until no contentChanged is in the critical section
+ runningLock.lock();
Review Comment:
I am sorry, I didn't understand the comment.
Original code was :
```
if (running.stop()) {
registration.unregister();
runningMonitor.leave();
}
```
And I have changed it to below
```
if (stopFlagSet()) {
// Wait until no contentChanged is in the critical section
runningLock.lock();
try {
registration.unregister();
} finally {
runningLock.unlock();
}
}
```
and it is only `unregisters` if the current thread is setting the flag to
stop.
--
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]