From: Jamo Luhrsen Date: Fri, 20 Mar 2020 18:47:48 +0000 (-0700) Subject: Fix checkstyle and spotbugs issues X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=939c0ed273421a9da77f96fa1ac33775670341d8;p=dlux.git Fix checkstyle and spotbugs issues When upgrading to odlparent 6.0.4, these problems end up as ERROR and not just WARN. Signed-off-by: Jamo Luhrsen Change-Id: I248d7b882f9691be69772ef371bf809f7ce79deb Signed-off-by: Jamo Luhrsen --- diff --git a/loader/api/src/main/java/org/opendaylight/dlux/loader/DluxModule.java b/loader/api/src/main/java/org/opendaylight/dlux/loader/DluxModule.java index b269a1a2..f504e177 100644 --- a/loader/api/src/main/java/org/opendaylight/dlux/loader/DluxModule.java +++ b/loader/api/src/main/java/org/opendaylight/dlux/loader/DluxModule.java @@ -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); } } diff --git a/loader/api/src/main/java/org/opendaylight/dlux/loader/DluxModuleLoader.java b/loader/api/src/main/java/org/opendaylight/dlux/loader/DluxModuleLoader.java index c48fc673..fa15b465 100644 --- a/loader/api/src/main/java/org/opendaylight/dlux/loader/DluxModuleLoader.java +++ b/loader/api/src/main/java/org/opendaylight/dlux/loader/DluxModuleLoader.java @@ -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); } diff --git a/loader/api/src/main/java/org/opendaylight/dlux/loader/Module.java b/loader/api/src/main/java/org/opendaylight/dlux/loader/Module.java index a204cab8..e17ea64a 100644 --- a/loader/api/src/main/java/org/opendaylight/dlux/loader/Module.java +++ b/loader/api/src/main/java/org/opendaylight/dlux/loader/Module.java @@ -13,6 +13,7 @@ import java.util.List; /** * Copyright (c) 2014 Inocybe Technologies, and others. All rights reserved. * + *

* 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 cssDependencies; diff --git a/loader/impl/src/main/java/org/opendaylight/dlux/loader/implementation/DluxLoader.java b/loader/impl/src/main/java/org/opendaylight/dlux/loader/implementation/DluxLoader.java index 9ff7508a..c818f659 100644 --- a/loader/impl/src/main/java/org/opendaylight/dlux/loader/implementation/DluxLoader.java +++ b/loader/impl/src/main/java/org/opendaylight/dlux/loader/implementation/DluxLoader.java @@ -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."); } } diff --git a/loader/impl/src/main/java/org/opendaylight/dlux/loader/implementation/DluxLoaderIndexServlet.java b/loader/impl/src/main/java/org/opendaylight/dlux/loader/implementation/DluxLoaderIndexServlet.java index 828da505..b743ef8e 100644 --- a/loader/impl/src/main/java/org/opendaylight/dlux/loader/implementation/DluxLoaderIndexServlet.java +++ b/loader/impl/src/main/java/org/opendaylight/dlux/loader/implementation/DluxLoaderIndexServlet.java @@ -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;