You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2021/10/25 15:50:25 UTC
[felix-dev] branch master updated: FELIX-6464 fix some more
potential NPEs (#112)
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new d0bd140 FELIX-6464 fix some more potential NPEs (#112)
d0bd140 is described below
commit d0bd14000d7d79283062398ea06a84c993610115
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Oct 25 17:50:18 2021 +0200
FELIX-6464 fix some more potential NPEs (#112)
---
.../internal/core/CapabilitiesPrinter.java | 25 +++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/CapabilitiesPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/CapabilitiesPrinter.java
index 5c1cb34..f9d19a1 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/CapabilitiesPrinter.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/CapabilitiesPrinter.java
@@ -32,6 +32,7 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.namespace.HostNamespace;
import org.osgi.framework.namespace.PackageNamespace;
import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleWire;
import org.osgi.framework.wiring.BundleWiring;
@@ -61,18 +62,27 @@ public class CapabilitiesPrinter extends AbstractConfigurationPrinter
for ( Bundle bundle : getBundleContext().getBundles() )
{
BundleWiring wiring = bundle.adapt( BundleWiring.class );
-
- List<BundleCapability> capabilities = wiring.getCapabilities( null ).stream()
+ if ( wiring == null )
+ {
+ continue;
+ }
+ List<BundleCapability> capabilities = wiring.getCapabilities( null );
+ if ( capabilities == null )
+ {
+ continue;
+ }
+ // which capabilities to filter?
+ List<BundleCapability> filteredCapabilities = capabilities.stream()
.filter( c -> EXCLUDED_NAMESPACES_PREDICATE.test(c.getNamespace()) )
.collect( Collectors.toList() );
- if ( capabilities.isEmpty() )
+ if ( filteredCapabilities.isEmpty() )
{
// skip bundles not exporting capabilities
continue;
}
ConfigurationRender.infoLine( printWriter, null, "Bundle", bundle.getSymbolicName() + " (" + bundle.getBundleId() + ")" );
- for ( BundleCapability capability : capabilities )
+ for ( BundleCapability capability : filteredCapabilities )
{
ConfigurationRender.infoLine( printWriter, " ", "Capability namespace", capability.getNamespace() );
String attributes = dumpTypedAttributes( capability.getAttributes() );
@@ -85,7 +95,12 @@ public class CapabilitiesPrinter extends AbstractConfigurationPrinter
{
ConfigurationRender.infoLine( printWriter, " ", "Directives", directives );
}
- String requirerBundles = wiring.getProvidedWires( capability.getNamespace() ).stream()
+ List<BundleWire> wires = wiring.getRequiredWires( capability.getNamespace() );
+ if ( wires == null )
+ {
+ continue;
+ }
+ String requirerBundles = wires.stream()
.map( w -> w.getRequirer().getSymbolicName() + " (" + w.getRequirer().getBundle().getBundleId() + ") with directives: " + dumpDirectives( w.getRequirement().getDirectives() ) )
.collect( Collectors.joining( ", ") );
if ( !requirerBundles.isEmpty() )