Fix checkstyle and spotbugs issues 57/88557/2
authorJamo Luhrsen <jluhrsen@gmail.com>
Fri, 20 Mar 2020 18:47:48 +0000 (11:47 -0700)
committerJamo Luhrsen <jluhrsen@gmail.com>
Fri, 20 Mar 2020 22:20:45 +0000 (15:20 -0700)
When upgrading to odlparent 6.0.4, these problems end up as ERROR and
not just WARN.

Signed-off-by: Jamo Luhrsen <jluhrsen@gmail.com>
Change-Id: I248d7b882f9691be69772ef371bf809f7ce79deb
Signed-off-by: Jamo Luhrsen <jluhrsen@gmail.com>
loader/api/src/main/java/org/opendaylight/dlux/loader/DluxModule.java
loader/api/src/main/java/org/opendaylight/dlux/loader/DluxModuleLoader.java
loader/api/src/main/java/org/opendaylight/dlux/loader/Module.java
loader/impl/src/main/java/org/opendaylight/dlux/loader/implementation/DluxLoader.java
loader/impl/src/main/java/org/opendaylight/dlux/loader/implementation/DluxLoaderIndexServlet.java

index b269a1a22b8c39b83378efe2be2ec588b1dd7f49..f504e1774788ab2d1abc9f42ffbfa01dcc6d8273 100644 (file)
@@ -9,10 +9,10 @@
 package org.opendaylight.dlux.loader;
 
 import com.google.common.base.Preconditions;
+import org.osgi.service.http.HttpService;
 import org.osgi.service.http.NamespaceException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.osgi.service.http.HttpService;
 
 /**
  * At startup of each karaf bundle, each UI module creates an instance of this class
@@ -22,14 +22,14 @@ import org.osgi.service.http.HttpService;
 
 public class DluxModule extends Module {
 
-    final static Logger logger = LoggerFactory.getLogger(DluxModule.class);
+    private static final Logger LOG = LoggerFactory.getLogger(DluxModule.class);
 
     /**
      * http Service is required to register resources for the specified url.
      */
     private HttpService httpService;
     /**
-     * loader to enable this module with dlux
+     * loader to enable this module with dlux.
      */
     private DluxModuleLoader loader;
 
@@ -49,28 +49,31 @@ public class DluxModule extends Module {
         Preconditions.checkNotNull(url, "module url is missing. Module can not be instantiated");
         Preconditions.checkNotNull(directory, "resource directory is missing. Module can not be instantiated");
 
-        logger.info("Registering resources for url {}", url);
+        LOG.info("Registering resources for url {}", url);
         try {
             httpService.registerResources(url, directory, null);
         } catch (NamespaceException e) {
-            logger.error("Exception occurred while registering resources with http service.", e);
+            LOG.error("Exception occurred while registering resources with http service.", e);
         }
 
-        if(loader != null) {
-            Preconditions.checkNotNull(moduleName, "module name is missing. Module can not be registered with dlux");
-            Preconditions.checkNotNull(requireJs, "requireJs module name is missing. Module can not be registered with dlux");
-            Preconditions.checkNotNull(angularJs, "angularJs module name is missing. Module can not be registered with dlux");
-            logger.info("Registering angularJS and requireJs modules for {}", moduleName);
+        if (loader != null) {
+            Preconditions.checkNotNull(moduleName,
+                    "module name is missing. Module can not be registered with dlux");
+            Preconditions.checkNotNull(requireJs,
+                    "requireJs module name is missing. Module can not be registered with dlux");
+            Preconditions.checkNotNull(angularJs,
+                    "angularJs module name is missing. Module can not be registered with dlux");
+            LOG.info("Registering angularJS and requireJs modules for {}", moduleName);
             loader.addModule(this);
         }
     }
 
     public void clean() {
-        logger.info("Unregistering resources for url {}", url);
+        LOG.info("Unregistering resources for url {}", url);
 
         httpService.unregister(url);
 
-        if(loader != null) {
+        if (loader != null) {
             loader.removeModule(this);
         }
     }
index c48fc67365cfc1330ae9a9423d134a0f89b0de47..fa15b46519fadac4056a4726b571f4bef631ef7e 100644 (file)
@@ -13,7 +13,7 @@ package org.opendaylight.dlux.loader;
  */
 public interface DluxModuleLoader {
 
-    public void addModule(Module module);
+    void addModule(Module module);
 
-    public void removeModule(Module module);
+    void removeModule(Module module);
 }
index a204cab8ef61988f2452e8221715c98a1dc6a755..e17ea64afb27289c691dc4c4d18ddf6ba4f6d4fd 100644 (file)
@@ -13,6 +13,7 @@ import java.util.List;
 /**
  * Copyright (c) 2014 Inocybe Technologies, and others. All rights reserved.
  *
+ * <p>
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -20,32 +21,32 @@ import java.util.List;
 
 public abstract class Module {
     /**
-     * Name of the dlux module
+     * Name of the dlux module.
      */
     String moduleName;
 
     /**
-     * url via the module can be accessed
+     * url via the module can be accessed.
      */
     String url;
 
     /**
-     * Location of resources to be registered
+     * Location of resources to be registered.
      */
     String directory;
 
     /**
-     * Name of the your requireJS module
+     * Name of the your requireJS module.
      */
     String requireJs;
 
     /**
-     * Name of the angularJs module
+     * Name of the angularJs module.
      */
     String angularJs;
 
     /**
-     * List of external or internal css dependencies
+     * List of external or internal css dependencies.
      */
     List<String> cssDependencies;
 
index 9ff7508a3b6ae4db2c0bf2b96f598660b37f13fd..c818f659082ae0aa29dfd4aecb0777d04db9b0c7 100644 (file)
@@ -25,7 +25,7 @@ import java.util.List;
 public class DluxLoader implements DluxModuleLoader {
 
     private DluxLoaderIndexServlet index;
-    private static Logger logger = LoggerFactory.getLogger(DluxLoader.class);
+    private static final Logger LOG = LoggerFactory.getLogger(DluxLoader.class);
 
     /**
      * List of modules registered with dlux
@@ -65,7 +65,7 @@ public class DluxLoader implements DluxModuleLoader {
         index = new DluxLoaderIndexServlet(this);
         httpService.registerServlet(SERVLET_URL, index, null, null);
         httpService.registerResources(RESOURCE_URL, RESOURCE_DIRECTORY, null);
-        logger.info("DluxLoader Service initialization complete.");
+        LOG.info("DluxLoader Service initialization complete.");
     }
 
 }
index 828da5057abe7ebdf43cfd232db622c72bee640e..b743ef8ec44ea3acf5eeb721e5b4fc0f7a575606 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.dlux.loader.implementation;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.opendaylight.dlux.loader.Module;
 import org.opendaylight.dlux.loader.exception.DluxLoaderException;
 import org.slf4j.Logger;
@@ -31,7 +32,7 @@ import java.util.Properties;
 public class DluxLoaderIndexServlet extends HttpServlet{
 
     private static final long serialVersionUID = 1L;
-    private static Logger logger = LoggerFactory.getLogger(DluxLoaderIndexServlet.class);
+    private static final Logger LOG = LoggerFactory.getLogger(DluxLoaderIndexServlet.class);
 
     private String DEFINEJS_PROPERTY = "defineJS";
 
@@ -53,6 +54,7 @@ public class DluxLoaderIndexServlet extends HttpServlet{
 
     private final String NEWLINE = "\n";
 
+    @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "Maintenance Update")
     private final DluxLoader loader;
 
     private final String UTF_CHARSET = "UTF-8";
@@ -89,7 +91,7 @@ public class DluxLoaderIndexServlet extends HttpServlet{
             prop.load(inputStream);
 
         } catch (IOException e) {
-            logger.error("Could not load properties from input stream", e);
+            LOG.error("Could not load properties from input stream", e);
             throw new DluxLoaderException("Dlux Loader Servlet initialization failed. ", e);
         }
         return prop;
@@ -106,7 +108,7 @@ public class DluxLoaderIndexServlet extends HttpServlet{
             }
 
         } catch (IOException e) {
-            logger.error("Could not load index html from input stream", e);
+            LOG.error("Could not load index html from input stream", e);
             throw new DluxLoaderException("Dlux Loader Servlet initialization failed. ", e);
         }
         return indexHTMLContent;