You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2023/07/14 10:07:29 UTC
[logging-log4j2] branch main updated: NPE in `OsgiServiceLocator`
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/main by this push:
new e0fe3b0d2b NPE in `OsgiServiceLocator`
e0fe3b0d2b is described below
commit e0fe3b0d2b949233e9c3da813822a157ebe0b797
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Fri Jul 14 12:05:15 2023 +0200
NPE in `OsgiServiceLocator`
---
.../org/apache/logging/log4j/util/OsgiServiceLocator.java | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/OsgiServiceLocator.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/OsgiServiceLocator.java
index 8142b7ff19..86f2573741 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/OsgiServiceLocator.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/OsgiServiceLocator.java
@@ -65,12 +65,13 @@ public class OsgiServiceLocator {
"Unable to load OSGI services: The bundle has no valid BundleContext for serviceType = {}, lookup = {}, lookupClass = {}, bundle = {}",
serviceType, lookup, lookupClass, bundle);
}
- }
- try {
- return ctx.getServiceReferences(serviceType, null).stream().map(ctx::getService);
- } catch (Throwable e) {
- if (verbose) {
- StatusLogger.getLogger().error("Unable to load OSGI services for service {}", serviceType, e);
+ } else {
+ try {
+ return ctx.getServiceReferences(serviceType, null).stream().map(ctx::getService);
+ } catch (Throwable e) {
+ if (verbose) {
+ StatusLogger.getLogger().error("Unable to load OSGI services for service {}", serviceType, e);
+ }
}
}
}