Skip to content

Commit 877ecc1

Browse files
committed
NPE in OsgiServiceLocator
1 parent 2d3ab52 commit 877ecc1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

log4j-api/src/main/java/org/apache/logging/log4j/util/OsgiServiceLocator.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ public static <T> Stream<T> loadServices(final Class<T> serviceType, final Looku
6565
"Unable to load OSGI services: The bundle has no valid BundleContext for serviceType = {}, lookup = {}, lookupClass = {}, bundle = {}",
6666
serviceType, lookup, lookupClass, bundle);
6767
}
68-
}
69-
try {
70-
return ctx.getServiceReferences(serviceType, null).stream().map(ctx::getService);
71-
} catch (Throwable e) {
72-
if (verbose) {
73-
StatusLogger.getLogger().error("Unable to load OSGI services for service {}", serviceType, e);
68+
} else {
69+
try {
70+
return ctx.getServiceReferences(serviceType, null).stream().map(ctx::getService);
71+
} catch (Throwable e) {
72+
if (verbose) {
73+
StatusLogger.getLogger().error("Unable to load OSGI services for service {}", serviceType, e);
74+
}
7475
}
7576
}
7677
}

0 commit comments

Comments
 (0)