daniancu opened a new pull request, #54:
URL: https://github.com/apache/sling-org-apache-sling-event/pull/54

   ## Summary
   
   - **Remove `stopProcessing()` from `unbindJobProcessingEnabledCondition()`** 
so topology state survives readiness condition removal — the core fix enabling 
recovery after transient probe blips
   - **Update `notifyListeners()` and `addListener()`** to send combined state 
(`caps != null && isJobProcessingEnabled()`) ensuring all listeners — including 
`JobSchedulerImpl` — correctly stop when readiness condition is absent
   - **Add 3 new unit tests** covering condition toggle with topology 
preservation, `addListener()` combined-state contract, and rapid toggle stress
   
   ## Context
   
   When the readiness condition is removed (e.g. during a transient K8S probe 
failure), `unbindJobProcessingEnabledCondition()` called `stopProcessing()` 
which destroyed `topologyCapabilities`. When the condition returned, 
`notifyListeners()` sent `active=false` (because topology was null) and job 
processing never resumed — requiring an unrelated topology event to recover.
   
   Additionally, `notifyListeners()` and `addListener()` only sent `caps != 
null` to listeners, ignoring the readiness condition state. This meant 
`JobSchedulerImpl` would continue scheduling jobs even when the readiness 
condition was absent.
   
   ## Changes
   
   1. **`unbindJobProcessingEnabledCondition()`**: Remove `stopProcessing()` 
call — preserve topology state so recovery is immediate when the condition 
returns
   2. **`notifyListeners()`**: Send `caps != null && isJobProcessingEnabled()` 
instead of just `caps != null` — all listeners see the correct combined state
   3. **`addListener()`**: Same combined-state logic for the initial callback 
on subscription — ensures freshly registered listeners don't become active when 
the condition is absent
   
   ## Test plan
   
   - [x] All 112 existing unit tests pass (0 failures, 0 errors)
   - [x] New: `testConditionTogglePreservesTopology` — verifies topology 
survives unbind/rebind and listeners get correct active state
   - [x] New: `testAddListenerSendsCombinedState` — verifies `addListener()` 
sends `false` when topology exists but condition is absent (JobSchedulerImpl 
startup path)
   - [x] New: `testRapidConditionToggle` — verifies topology and state 
consistency after rapid toggles


-- 
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]

Reply via email to