svn commit: r1811432 - /ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1811432 - /ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java

mbrohl
Author: mbrohl
Date: Sat Oct  7 14:49:16 2017
New Revision: 1811432

URL: http://svn.apache.org/viewvc?rev=1811432&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.catalina.container.
(OFBIZ-9639)

Thanks Dennis Balkir for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java

Modified: ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java?rev=1811432&r1=1811431&r2=1811432&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java Sat Oct  7 14:49:16 2017
@@ -169,9 +169,8 @@ public class CatalinaContainer implement
         Property defaultHostProp = engineConfig.getProperty("default-host");
         if (defaultHostProp == null) {
             throw new ContainerException("default-host element of server property is required for catalina!");
-        } else {
-            tomcat.setHostname(defaultHostProp.value);
         }
+        tomcat.setHostname(defaultHostProp.value);
 
         if (ContainerConfig.getPropertyValue(cc, "use-naming", false)) {
             tomcat.enableNaming();
@@ -245,7 +244,7 @@ public class CatalinaContainer implement
         Property clusterProp = null;
 
         List<Property> clusterProps = engineConfig.getPropertiesWithValue("cluster");
-        if (clusterProps != null && clusterProps.size() > 1) {
+        if (clusterProps.size() > 1) {
             throw new ContainerException("Only one cluster configuration allowed per engine");
         }
 
@@ -345,7 +344,7 @@ public class CatalinaContainer implement
     }
 
     private List<Valve> prepareTomcatEngineValves(Property engineConfig) throws ContainerException {
-        List<Valve> engineValves = new ArrayList<Valve>();
+        List<Valve> engineValves = new ArrayList<>();
 
         // configure the CrossSubdomainSessionValve
         if (ContainerConfig.getPropertyValue(engineConfig, "enable-cross-subdomain-sessions", false)) {
@@ -424,12 +423,12 @@ public class CatalinaContainer implement
     private void loadWebapps(Tomcat tomcat, ContainerConfig.Configuration configuration, Property clusterProp) {
         ScheduledExecutorService executor = ExecutionPool.getScheduledExecutor(new ThreadGroup(module),
                 "catalina-startup", Runtime.getRuntime().availableProcessors(), 0, true);
-        List<Future<Context>> futures = new ArrayList<Future<Context>>();
+        List<Future<Context>> futures = new ArrayList<>();
 
         List<ComponentConfig.WebappInfo> webResourceInfos = ComponentConfig.getAllWebappResourceInfos();
         Collections.reverse(webResourceInfos); // allow higher level webapps to override lower ones
 
-        Set<String> webappsMounts = new HashSet<String>();
+        Set<String> webappsMounts = new HashSet<>();
         webResourceInfos.forEach(appInfo -> webappsMounts.addAll(getWebappMounts(appInfo)));
 
         for (ComponentConfig.WebappInfo appInfo: webResourceInfos) {
@@ -450,7 +449,7 @@ public class CatalinaContainer implement
     }
 
     private List<String> getWebappMounts(ComponentConfig.WebappInfo webappInfo) {
-        List<String> allAppsMounts = new ArrayList<String>();
+        List<String> allAppsMounts = new ArrayList<>();
         String engineName = webappInfo.server;
         String mount = webappInfo.getContextRoot();
         List<String> virtualHosts = webappInfo.getVirtualHosts();
@@ -563,10 +562,9 @@ public class CatalinaContainer implement
             if (webXmlFile.exists()) {
                 Document webXmlDoc = UtilXml.readXmlDocument(webXmlUrl);
                 return appIsDistributable && webXmlDoc.getElementsByTagName("distributable").getLength() > 0;
-            } else {
-                Debug.logInfo(webXmlFilePath + " not found.", module);
-                return appIsDistributable;
             }
+            Debug.logInfo(webXmlFilePath + " not found.", module);
+            return appIsDistributable;
         } catch (SAXException | ParserConfigurationException | IOException e) {
             throw new ContainerException(e);
         }