You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by da...@apache.org on 2026/07/06 15:44:57 UTC
(jackrabbit-oak) branch OAK-12300 created (now 326724e935)
This is an automated email from the ASF dual-hosted git repository.
rishabhdaim pushed a change to branch OAK-12300
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
at 326724e935 OAK-XXXXX: Remove ServiceListener after awaitServiceEvent completes
This branch includes the following new commits:
new 326724e935 OAK-XXXXX: Remove ServiceListener after awaitServiceEvent completes
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit-oak) 01/01: OAK-XXXXX: Remove ServiceListener after awaitServiceEvent completes
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rishabhdaim pushed a commit to branch OAK-12300
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 326724e935b7554fdcfd3e5b62e9f73448c2056b
Author: rishabhdaim <ri...@gmail.com>
AuthorDate: Mon Jul 6 21:06:41 2026 +0530
OAK-XXXXX: Remove ServiceListener after awaitServiceEvent completes
The EventServiceListener was never removed from the BundleContext after
awaitServiceEvent completed (either successfully or via timeout). This caused:
1. Resource leaks - listeners accumulated across test runs
2. Test interference - listeners from previous tests continued receiving events
3. Intermittent test failures - unrelated service events could be captured,
causing timeout errors when waiting for specific service events
Fix: Add try-finally block to ensure bundleContext.removeServiceListener()
is always called after the await completes, preventing listener accumulation
and cross-test event interference.
Co-authored-by: Copilot <22...@users.noreply.github.com>
---
.../oak/run/osgi/AbstractRepositoryFactoryTest.java | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/oak-pojosr/src/test/java/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.java b/oak-pojosr/src/test/java/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.java
index 3167e9168d..9b2cbd8a9d 100644
--- a/oak-pojosr/src/test/java/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.java
+++ b/oak-pojosr/src/test/java/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.java
@@ -194,11 +194,15 @@ public abstract class AbstractRepositoryFactoryTest {
EventServiceListener listener = new EventServiceListener(eventTypes, bundleContext, serviceFilter);
bundleContext.addServiceListener(listener);
- closure.run();
- if (!listener.getLatch().await(timeout, timeUnit)) {
- throw new AssertionError("Exceeded timeout waiting for service event matching " +
- "[eventTypes: " + eventTypes + ", filter: " + serviceFilter + "], " +
- "got " + listener.events.size() + " non matching events: [" + listener.events + "]");
+ try {
+ closure.run();
+ if (!listener.getLatch().await(timeout, timeUnit)) {
+ throw new AssertionError("Exceeded timeout waiting for service event matching " +
+ "[eventTypes: " + eventTypes + ", filter: " + serviceFilter + "], " +
+ "got " + listener.events.size() + " non matching events: [" + listener.events + "]");
+ }
+ } finally {
+ bundleContext.removeServiceListener(listener);
}
} catch (Exception e) {
throw new RuntimeException(e);