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

commit 2f3e05402c34a6b1097955ed06ffd14ae65d112b
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Thu Oct 13 09:22:15 2022 +0200

    Minor code clean up, make sure to check support if it is set before using
---
 .../plugins/ds/internal/ConfigurationSupport.java      |  2 +-
 .../plugins/ds/internal/WebConsolePlugin.java          | 18 ++++++++++--------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git 
a/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ConfigurationSupport.java
 
b/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ConfigurationSupport.java
index 749f35289b..667bb5c883 100644
--- 
a/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ConfigurationSupport.java
+++ 
b/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ConfigurationSupport.java
@@ -36,7 +36,7 @@ public class ConfigurationSupport {
         this.configAdminTracker = new ServiceTracker<Object, 
Object>(bundleContext, "org.osgi.service.cm.ConfigurationAdmin", null);
         this.metatypeTracker = new ServiceTracker<Object, 
Object>(bundleContext, "org.osgi.service.metatype.MetaTypeService", null);
 
-        configAdminTracker.open();
+        this.configAdminTracker.open();
         this.metatypeTracker.open();
     }
 
diff --git 
a/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java
 
b/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java
index c2cd13f056..a7c4715f61 100644
--- 
a/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java
+++ 
b/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java
@@ -70,7 +70,7 @@ class WebConsolePlugin extends SimpleWebConsolePlugin
     // templates
     private final String TEMPLATE;
 
-    private volatile ConfigurationSupport optionalSupport;
+    private volatile ConfigurationSupport support;
 
     private final ServiceComponentRuntime runtime;
 
@@ -87,10 +87,10 @@ class WebConsolePlugin extends SimpleWebConsolePlugin
 
     @Override
     public void deactivate() {
-        if ( this.optionalSupport != null )
+        if ( this.support != null )
         {
-            this.optionalSupport.close();
-            this.optionalSupport = null;
+            this.support.close();
+            this.support = null;
         }
         super.deactivate();
     }
@@ -100,7 +100,7 @@ class WebConsolePlugin extends SimpleWebConsolePlugin
     public void activate(final BundleContext bundleContext)
     {
         super.activate(bundleContext);
-        this.optionalSupport = new ConfigurationSupport(bundleContext);
+        this.support = new ConfigurationSupport(bundleContext);
     }
 
 
@@ -276,7 +276,8 @@ class WebConsolePlugin extends SimpleWebConsolePlugin
         }
         jw.key("pid"); //$NON-NLS-1$
         jw.value(pid);
-        if (this.optionalSupport.isConfigurable(
+        final ConfigurationSupport localSupport = this.support;
+        if (localSupport != null && localSupport.isConfigurable(
                 
this.getBundleContext().getBundle(0).getBundleContext().getBundle(desc.bundle.id),
                 configurationPid))
         {
@@ -482,8 +483,9 @@ class WebConsolePlugin extends SimpleWebConsolePlugin
         Bundle bundle = 
this.getBundleContext().getBundle(0).getBundleContext().getBundle(desc.bundle.id);
         String[] configurationPids = desc.configurationPid;
 
-        Collection<String> passwordPropertyIds =
-                this.optionalSupport.getPasswordAttributeDefinitionIds(bundle, 
configurationPids);
+        final ConfigurationSupport localSupport = this.support;
+        Collection<String> passwordPropertyIds = localSupport != null ?
+                localSupport.getPasswordAttributeDefinitionIds(bundle, 
configurationPids) : Collections.emptyList();
 
         if (props != null)
         {

Reply via email to