Fix race condition in reflectorRunOnce test between list completion and watch start#4632
Conversation
…stopping Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Copilot The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@copilot looks like you removed validation that the mockResourceVersion was set, and also I'm not sure the Thread.sleep() is required. |
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Addressed in 373ebe0. Re-added On |
|
@copilot I don't like that we're just hanging this thread. I think that this is just a hacky way to make sure that the watch is ongoing before we call stop. Maybe we should just add a second countdown latch that waits until stop is called before counting down. |
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Done in e52c5a4. Replaced |
505d9fc
into
dependabot/maven/org.apache.felix-maven-bundle-plugin-6.0.2
reflectorRunOncetest waited forlastSyncResourceVersion(set before watch starts), allowingstop()to be called beforewatch()was invoked;Awaitility.await().forever()doesn't actually block without.until()reflectorRunOnceto use aCountDownLatchthat signals whenwatch()is actually called, ensuringstop()is only called after the watch has startedmockResourceVersionassertion (assertThat(reflectorRunnable.getLastSyncResourceVersion()).isEqualTo(mockResourceVersion)) that was accidentally removedThread.sleep(1 hour)with a secondCountDownLatch(watchCanReturnLatch):watch()mock awaits this latch;finallyblock callsstop()first then counts down the latch, ensuring the reflector seesisActive=falsewhenwatch()returns💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.