struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [4/5] struts git commit: Minor code improvements's in the struts core module
Date Mon, 08 Jun 2015 17:27:22 GMT
http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/components/template/JspTemplateEngine.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/components/template/JspTemplateEngine.java b/core/src/main/java/org/apache/struts2/components/template/JspTemplateEngine.java
index 95b4ed6..077e70d 100644
--- a/core/src/main/java/org/apache/struts2/components/template/JspTemplateEngine.java
+++ b/core/src/main/java/org/apache/struts2/components/template/JspTemplateEngine.java
@@ -21,21 +21,18 @@
 
 package org.apache.struts2.components.template;
 
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.jsp.PageContext;
-
 import com.opensymphony.xwork2.inject.Inject;
+import com.opensymphony.xwork2.util.ValueStack;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.components.Include;
 import org.apache.struts2.components.UIBean;
 
-import com.opensymphony.xwork2.util.ValueStack;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.PageContext;
+import java.util.List;
 
 /**
  * JSP based template engine.
@@ -53,9 +50,7 @@ public class JspTemplateEngine extends BaseTemplateEngine {
     public void renderTemplate(TemplateRenderingContext templateContext) throws Exception {
         Template template = templateContext.getTemplate();
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Trying to render template " + template + ", repeating through parents until we succeed");
-        }
+        LOG.debug("Trying to render template [{}], repeating through parents until we succeed", template);
         UIBean tag = templateContext.getTag();
         ValueStack stack = templateContext.getStack();
         stack.push(tag);
@@ -77,7 +72,7 @@ public class JspTemplateEngine extends BaseTemplateEngine {
         }
 
         if (!success) {
-            LOG.error("Could not render JSP template " + templateContext.getTemplate());
+            LOG.error("Could not render JSP template {}", templateContext.getTemplate());
 
             if (exception != null) {
                 throw exception;

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/components/template/Template.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/components/template/Template.java b/core/src/main/java/org/apache/struts2/components/template/Template.java
index d4f39e6..361dcb6 100644
--- a/core/src/main/java/org/apache/struts2/components/template/Template.java
+++ b/core/src/main/java/org/apache/struts2/components/template/Template.java
@@ -83,7 +83,7 @@ public class Template implements Cloneable {
      * @return a string in the format <code>/dir/theme/name</code>.
      */
     public String toString() {
-        return "/" + dir + "/" + theme + "/" + name;
+        return new StringBuilder().append("/").append(dir).append("/").append(theme).append("/").append(name).toString();
     }
 
     protected Object clone() throws CloneNotSupportedException {

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java b/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java
index 0a2e97a..bd8c3b4 100644
--- a/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java
+++ b/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java
@@ -24,6 +24,7 @@ package org.apache.struts2.components.template;
 import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.Inject;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.struts2.StrutsConstants;
 
 import java.util.Collections;
@@ -36,11 +37,13 @@ import java.util.Set;
  */
 public class TemplateEngineManager {
 
-    /** The default template extenstion is <code>ftl</code>. */
+    /**
+     * The default template extension is <code>ftl</code>.
+     */
     public static final String DEFAULT_TEMPLATE_TYPE = "ftl";
 
-    
-    Map<String,EngineFactory> templateEngines = new HashMap<String,EngineFactory>();
+
+    Map<String, EngineFactory> templateEngines = new HashMap<>();
     Container container;
     String defaultTemplateType;
     
@@ -52,13 +55,12 @@ public class TemplateEngineManager {
     @Inject
     public void setContainer(Container container) {
         this.container = container;
-        Map<String,EngineFactory> map = new HashMap<String,EngineFactory>();
+        Map<String, EngineFactory> map = new HashMap<>();
         Set<String> prefixes = container.getInstanceNames(TemplateEngine.class);
         for (String prefix : prefixes) {
             map.put(prefix, new LazyEngineFactory(prefix));
         }
         this.templateEngines = Collections.unmodifiableMap(map);
-        
     }
     
     /**
@@ -89,9 +91,9 @@ public class TemplateEngineManager {
     public TemplateEngine getTemplateEngine(Template template, String templateTypeOverride) {
         String templateType = DEFAULT_TEMPLATE_TYPE;
         String templateName = template.toString();
-        if (templateName.indexOf(".") > 0) {
-            templateType = templateName.substring(templateName.indexOf(".") + 1);
-        } else if (templateTypeOverride !=null && templateTypeOverride.length() > 0) {
+        if (StringUtils.contains(templateName, ".")) {
+            templateType = StringUtils.substring(templateName, StringUtils.indexOf(templateName, ".") + 1);
+        } else if (StringUtils.isNotBlank(templateTypeOverride)) {
             templateType = templateTypeOverride;
         } else {
             String type = defaultTemplateType;
@@ -104,7 +106,7 @@ public class TemplateEngineManager {
 
     /** Abstracts loading of the template engine */
     interface EngineFactory {
-        public TemplateEngine create();
+        TemplateEngine create();
     }    
 
     /** 

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java b/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java
index 87fc2b8..6e1db53 100644
--- a/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java
+++ b/core/src/main/java/org/apache/struts2/components/template/VelocityTemplateEngine.java
@@ -21,23 +21,21 @@
 
 package org.apache.struts2.components.template;
 
-import java.io.IOException;
-import java.io.Writer;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import com.opensymphony.xwork2.inject.Inject;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.views.velocity.VelocityManager;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.context.Context;
 
-import com.opensymphony.xwork2.inject.Inject;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Velocity based template engine.
@@ -84,7 +82,7 @@ public class VelocityTemplateEngine extends BaseTemplateEngine {
         }
 
         if (template == null) {
-            LOG.error("Could not load template " + templateContext.getTemplate());
+            LOG.error("Could not load template {}", templateContext.getTemplate());
             if (exception != null) {
                 throw exception;
             } else {
@@ -92,9 +90,7 @@ public class VelocityTemplateEngine extends BaseTemplateEngine {
             }
         }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Rendering template " + templateName);
-        }
+        LOG.debug("Rendering template {}", templateName);
 
         Context context = velocityManager.createContext(templateContext.getStack(), req, res);
 

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/config/AbstractBeanSelectionProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/config/AbstractBeanSelectionProvider.java b/core/src/main/java/org/apache/struts2/config/AbstractBeanSelectionProvider.java
index 0bc7f30..f8a696a 100644
--- a/core/src/main/java/org/apache/struts2/config/AbstractBeanSelectionProvider.java
+++ b/core/src/main/java/org/apache/struts2/config/AbstractBeanSelectionProvider.java
@@ -4,15 +4,11 @@ import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.config.BeanSelectionProvider;
 import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationException;
-import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.inject.ContainerBuilder;
-import com.opensymphony.xwork2.inject.Context;
-import com.opensymphony.xwork2.inject.Factory;
-import com.opensymphony.xwork2.inject.Scope;
+import com.opensymphony.xwork2.inject.*;
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.util.Properties;
 
@@ -87,8 +83,6 @@ public abstract class AbstractBeanSelectionProvider implements BeanSelectionProv
         }
     }
 
-
-
     static class ObjectFactoryDelegateFactory implements Factory {
 
         String name;
@@ -107,6 +101,5 @@ public abstract class AbstractBeanSelectionProvider implements BeanSelectionProv
                 throw new ConfigurationException("Unable to load bean "+type.getName()+" ("+name+")");
             }
         }
-
     }
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/config/DefaultSettings.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/config/DefaultSettings.java b/core/src/main/java/org/apache/struts2/config/DefaultSettings.java
index cc30f48..8fc9a49 100644
--- a/core/src/main/java/org/apache/struts2/config/DefaultSettings.java
+++ b/core/src/main/java/org/apache/struts2/config/DefaultSettings.java
@@ -22,8 +22,8 @@
 package org.apache.struts2.config;
 
 import com.opensymphony.xwork2.util.location.Location;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.StrutsConstants;
 
 import java.util.ArrayList;
@@ -56,7 +56,7 @@ public class DefaultSettings implements Settings {
      */
     public DefaultSettings() {
 
-        ArrayList<Settings> list = new ArrayList<Settings>();
+        ArrayList<Settings> list = new ArrayList<>();
 
         // stuts.properties, default.properties
         try {
@@ -77,7 +77,7 @@ public class DefaultSettings implements Settings {
                 try {
                     list.add(new PropertiesSettings(name));
                 } catch (Exception e) {
-                    LOG.error("DefaultSettings: Could not find " + name + ".properties. Skipping.");
+                    LOG.error("DefaultSettings: Could not find {}.properties. Skipping.", name);
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java b/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java
index 132c24e..c8a1632 100644
--- a/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java
+++ b/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java
@@ -69,7 +69,7 @@ class DelegatingSettings implements Settings {
     public Iterator list() {
         boolean workedAtAll = false;
 
-        Set<Object> settingList = new HashSet<Object>();
+        Set<Object> settingList = new HashSet<>();
         UnsupportedOperationException e = null;
 
         for (Settings delegate : delegates) {
@@ -83,7 +83,6 @@ class DelegatingSettings implements Settings {
                 workedAtAll = true;
             } catch (UnsupportedOperationException ex) {
                 e = ex;
-
                 // Try next delegate
             }
         }

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java b/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java
index 3bbf9b4..06bc744 100644
--- a/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java
+++ b/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java
@@ -25,8 +25,8 @@ import com.opensymphony.xwork2.util.ClassLoaderUtil;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
 import com.opensymphony.xwork2.util.location.Location;
 import com.opensymphony.xwork2.util.location.LocationImpl;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.StrutsException;
 
 import java.io.IOException;
@@ -56,9 +56,7 @@ class PropertiesSettings implements Settings {
         URL settingsUrl = ClassLoaderUtil.getResource(name + ".properties", getClass());
         
         if (settingsUrl == null) {
-            if (LOG.isDebugEnabled()) {
-        	LOG.debug(name + ".properties missing");
-            }
+            LOG.debug("{}.properties missing", name);
             settings = new LocatableProperties();
             return;
         }
@@ -71,15 +69,13 @@ class PropertiesSettings implements Settings {
             in = settingsUrl.openStream();
             settings.load(in);
         } catch (IOException e) {
-            throw new StrutsException("Could not load " + name + ".properties:" + e, e);
+            throw new StrutsException("Could not load " + name + ".properties: " + e, e);
         } finally {
             if(in != null) {
                 try {
                     in.close();
                 } catch(IOException io) {
-                    if (LOG.isWarnEnabled()) {
                 	LOG.warn("Unable to close input stream", io);
-                    }
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java b/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
index f09d6f3..cca80b7 100644
--- a/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
+++ b/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java
@@ -21,18 +21,6 @@
 
 package org.apache.struts2.config;
 
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.ServletContext;
-
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
@@ -40,8 +28,15 @@ import com.opensymphony.xwork2.inject.ContainerBuilder;
 import com.opensymphony.xwork2.inject.Context;
 import com.opensymphony.xwork2.inject.Factory;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import javax.servlet.ServletContext;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.*;
 
 /**
  * Override Xwork class so we can use an arbitrary config file
@@ -128,7 +123,7 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
             }
         }
         if (url != null) {
-            List<URL> list = new ArrayList<URL>();
+            List<URL> list = new ArrayList<>();
             list.add(url);
             return list.iterator();
         } else {
@@ -139,9 +134,7 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
     protected URL findInFileSystem(String fileName) throws IOException {
         URL url = null;
         File file = new File(fileName);
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Trying to load file " + file);
-        }
+        LOG.debug("Trying to load file: {}", file);
 
         // Trying relative path to original file
         if (!file.exists()) {

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java b/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
index 528e611..b0dd299 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
@@ -86,10 +86,10 @@ public class ActionContextCleanUp implements Filter {
             try {
                 Integer count = (Integer)request.getAttribute(COUNTER);
                 if (count == null) {
-                    count = Integer.valueOf(1);
+                    count = 1;
                 }
                 else {
-                    count = Integer.valueOf(count.intValue()+1);
+                    count = count.intValue() + 1;
                 }
                 request.setAttribute(COUNTER, count);
 
@@ -97,9 +97,9 @@ public class ActionContextCleanUp implements Filter {
 
                 chain.doFilter(request, response);
             } finally {
-                int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue();
+                int counterVal = ((Integer) request.getAttribute(COUNTER));
                 counterVal -= 1;
-                request.setAttribute(COUNTER, Integer.valueOf(counterVal));
+                request.setAttribute(COUNTER, counterVal);
                 cleanUp(request);
             }
         }
@@ -117,9 +117,7 @@ public class ActionContextCleanUp implements Filter {
         // should we clean up yet?
         Integer count = (Integer) req.getAttribute(COUNTER);
         if (count != null && count > 0 ) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("skipping cleanup counter="+count);
-            }
+            LOG.debug("Skipping cleanup counter: ", count);
             return;
         }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java b/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java
index 8185d02..ee75360 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java
@@ -23,11 +23,7 @@ package org.apache.struts2.dispatcher;
 
 import javax.servlet.ServletContext;
 import java.io.Serializable;
-import java.util.AbstractMap;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 
 /**
@@ -74,7 +70,7 @@ public class ApplicationMap extends AbstractMap implements Serializable {
      */
     public Set entrySet() {
         if (entries == null) {
-            entries = new HashSet<Object>();
+            entries = new HashSet<>();
 
             // Add servlet context attributes
             Enumeration enumeration = context.getAttributeNames();

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/ContainerHolder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ContainerHolder.java b/core/src/main/java/org/apache/struts2/dispatcher/ContainerHolder.java
index e0123e5..35cf147 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/ContainerHolder.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/ContainerHolder.java
@@ -12,7 +12,7 @@ import com.opensymphony.xwork2.inject.Container;
  */
 class ContainerHolder {
 
-    private static ThreadLocal<Container> instance = new ThreadLocal<Container>();
+    private static ThreadLocal<Container> instance = new ThreadLocal<>();
 
     public static void store(Container instance) {
         ContainerHolder.instance.set(instance);

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/DefaultDispatcherErrorHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/DefaultDispatcherErrorHandler.java b/core/src/main/java/org/apache/struts2/dispatcher/DefaultDispatcherErrorHandler.java
index 78ca2c8..d64b800 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/DefaultDispatcherErrorHandler.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/DefaultDispatcherErrorHandler.java
@@ -3,9 +3,10 @@ package org.apache.struts2.dispatcher;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.location.Location;
 import com.opensymphony.xwork2.util.location.LocationUtils;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
 import freemarker.template.Template;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsException;
 import org.apache.struts2.views.freemarker.FreemarkerManager;
@@ -39,7 +40,7 @@ public class DefaultDispatcherErrorHandler implements DispatcherErrorHandler {
 
     @Inject(StrutsConstants.STRUTS_DEVMODE)
     public void setDevMode(String devMode) {
-        this.devMode = "true".equalsIgnoreCase(devMode);
+        this.devMode = BooleanUtils.toBoolean(devMode);
     }
 
     public void init(ServletContext ctx) {
@@ -65,9 +66,7 @@ public class DefaultDispatcherErrorHandler implements DispatcherErrorHandler {
             // WW-1977: Only put errors in the request when code is a 500 error
             if (code == HttpServletResponse.SC_INTERNAL_SERVER_ERROR) {
                 // WW-4103: Only logs error when application error occurred, not Struts error
-                if (LOG.isErrorEnabled()) {
-                    LOG.error("Exception occurred during processing request: {}", e, e.getMessage());
-                }
+                LOG.error("Exception occurred during processing request: {}", e, e.getMessage());
                 // send a http error response to use the servlet defined error handler
                 // make the exception available to the web.xml defined error page
                 request.setAttribute("javax.servlet.error.exception", e);
@@ -86,7 +85,7 @@ public class DefaultDispatcherErrorHandler implements DispatcherErrorHandler {
     protected void handleErrorInDevMode(HttpServletResponse response, int code, Exception e) {
         LOG.debug("Exception occurred during processing request: {}", e, e.getMessage());
         try {
-            List<Throwable> chain = new ArrayList<Throwable>();
+            List<Throwable> chain = new ArrayList<>();
             Throwable cur = e;
             chain.add(cur);
             while ((cur = cur.getCause()) != null) {
@@ -101,9 +100,7 @@ public class DefaultDispatcherErrorHandler implements DispatcherErrorHandler {
             response.getWriter().close();
         } catch (Exception exp) {
             try {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Cannot show problem report!", exp);
-                }
+                LOG.debug("Cannot show problem report!", exp);
                 response.sendError(code, "Unable to show problem report:\n" + exp + "\n\n" + LocationUtils.getLocation(exp));
             } catch (IOException ex) {
                 // we're already sending an error, not much else we can do if more stuff breaks
@@ -112,7 +109,7 @@ public class DefaultDispatcherErrorHandler implements DispatcherErrorHandler {
     }
 
     protected HashMap<String, Object> createReportData(Exception e, List<Throwable> chain) {
-        HashMap<String,Object> data = new HashMap<String,Object>();
+        HashMap<String, Object> data = new HashMap<>();
         data.put("exception", e);
         data.put("unknown", Location.UNKNOWN);
         data.put("chain", chain);

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java b/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
index 4d27f49..fcdc7cf 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
@@ -22,8 +22,9 @@ package org.apache.struts2.dispatcher;
 
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
-import org.apache.logging.log4j.Logger;
+import org.apache.commons.lang3.BooleanUtils;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.dispatcher.ng.HostConfig;
 
@@ -35,11 +36,7 @@ import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URL;
 import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.List;
-import java.util.StringTokenizer;
+import java.util.*;
 
 /**
  * <b>Default implementation to server static content</b>
@@ -97,33 +94,33 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
     /**
      * Modify state of StrutsConstants.STRUTS_SERVE_STATIC_CONTENT setting.
      *
-     * @param val
+     * @param serveStaticContent
      *            New setting
      */
     @Inject(StrutsConstants.STRUTS_SERVE_STATIC_CONTENT)
-    public void setServeStaticContent(String val) {
-        serveStatic = "true".equals(val);
+    public void setServeStaticContent(String serveStaticContent) {
+        this.serveStatic = BooleanUtils.toBoolean(serveStaticContent);
     }
 
     /**
      * Modify state of StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE
      * setting.
      *
-     * @param val
+     * @param serveStaticBrowserCache
      *            New setting
      */
     @Inject(StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE)
-    public void setServeStaticBrowserCache(String val) {
-        serveStaticBrowserCache = "true".equals(val);
+    public void setServeStaticBrowserCache(String serveStaticBrowserCache) {
+        this.serveStaticBrowserCache = BooleanUtils.toBoolean(serveStaticBrowserCache);
     }
 
     /**
      * Modify state of StrutsConstants.STRUTS_I18N_ENCODING setting.
-     * @param val New setting
+     * @param encoding New setting
      */
     @Inject(StrutsConstants.STRUTS_I18N_ENCODING)
-    public void setEncoding(String val) {
-        encoding = val;
+    public void setEncoding(String encoding) {
+        this.encoding = encoding;
     }
 
     /*
@@ -155,7 +152,7 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
         if (packages == null) {
             return Collections.emptyList();
         }
-        List<String> pathPrefixes = new ArrayList<String>();
+        List<String> pathPrefixes = new ArrayList<>();
 
         StringTokenizer st = new StringTokenizer(packages, ", \n\t");
         while (st.hasMoreTokens()) {
@@ -213,9 +210,7 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
             try {
                 ifModifiedSince = request.getDateHeader("If-Modified-Since");
             } catch (Exception e) {
-                if (LOG.isWarnEnabled()) {
-                    LOG.warn("Invalid If-Modified-Since header value: '{}', ignoring", request.getHeader("If-Modified-Since"));
-                }
+                LOG.warn("Invalid If-Modified-Since header value: '{}', ignoring", request.getHeader("If-Modified-Since"));
             }
             long lastModifiedMillis = lastModifiedCal.getTimeInMillis();
             long now = cal.getTimeInMillis();

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
index 707c051..f8d9d9e 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -38,9 +38,11 @@ import com.opensymphony.xwork2.util.ValueStackFactory;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
 import com.opensymphony.xwork2.util.location.Location;
 import com.opensymphony.xwork2.util.location.LocationUtils;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
 import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsException;
@@ -82,13 +84,12 @@ public class Dispatcher {
     /**
      * Provide a thread local instance.
      */
-    private static ThreadLocal<Dispatcher> instance = new ThreadLocal<Dispatcher>();
+    private static ThreadLocal<Dispatcher> instance = new ThreadLocal<>();
 
     /**
      * Store list of DispatcherListeners.
      */
-    private static List<DispatcherListener> dispatcherListeners =
-        new CopyOnWriteArrayList<DispatcherListener>();
+    private static List<DispatcherListener> dispatcherListeners = new CopyOnWriteArrayList<>();
 
     /**
      * Store ConfigurationManager instance, set on init.
@@ -220,7 +221,7 @@ public class Dispatcher {
      */
     @Inject(value=StrutsConstants.STRUTS_DISABLE_REQUEST_ATTRIBUTE_VALUE_STACK_LOOKUP, required=false)
     public void setDisableRequestAttributeValueStackLookup(String disableRequestAttributeValueStackLookup) {
-        this.disableRequestAttributeValueStackLookup = "true".equalsIgnoreCase(disableRequestAttributeValueStackLookup);
+        this.disableRequestAttributeValueStackLookup = BooleanUtils.toBoolean(disableRequestAttributeValueStackLookup);
     }
 
     /**
@@ -278,9 +279,7 @@ public class Dispatcher {
     	// clean up ObjectFactory
         ObjectFactory objectFactory = getContainer().getInstance(ObjectFactory.class);
         if (objectFactory == null) {
-            if (LOG.isWarnEnabled()) {
         	LOG.warn("Object Factory is null, something is seriously wrong, no clean up will be performed");
-            }
         }
         if (objectFactory instanceof ObjectFactoryDestroyable) {
             try {
@@ -288,7 +287,7 @@ public class Dispatcher {
             }
             catch(Exception e) {
                 // catch any exception that may occurred during destroy() and log it
-                LOG.error("exception occurred while destroying ObjectFactory [{}]", e, objectFactory.toString());
+                LOG.error("Exception occurred while destroying ObjectFactory [{}]", objectFactory.toString(), e);
             }
         }
 
@@ -303,7 +302,7 @@ public class Dispatcher {
         }
 
         // clean up all interceptors by calling their destroy() method
-        Set<Interceptor> interceptors = new HashSet<Interceptor>();
+        Set<Interceptor> interceptors = new HashSet<>();
         Collection<PackageConfig> packageConfigs = configurationManager.getConfiguration().getPackageConfigs().values();
         for (PackageConfig packageConfig : packageConfigs) {
             for (Object config : packageConfig.getAllInterceptorConfigs().values()) {
@@ -441,11 +440,8 @@ public class Dispatcher {
 
     private void init_CheckWebLogicWorkaround(Container container) {
         // test whether param-access workaround needs to be enabled
-        if (servletContext != null && servletContext.getServerInfo() != null
-                && servletContext.getServerInfo().contains("WebLogic")) {
-            if (LOG.isInfoEnabled()) {
-        	LOG.info("WebLogic server detected. Enabling Struts parameter access work-around.");
-            }
+        if (servletContext != null && StringUtils.contains(servletContext.getServerInfo(), "WebLogic")) {
+            LOG.info("WebLogic server detected. Enabling Struts parameter access work-around.");
             paramsWorkaroundEnabled = true;
         } else {
             paramsWorkaroundEnabled = "true".equals(container.getInstance(String.class,
@@ -484,8 +480,7 @@ public class Dispatcher {
             errorHandler.init(servletContext);
 
         } catch (Exception ex) {
-            if (LOG.isErrorEnabled())
-                LOG.error("Dispatcher initialization failed", ex);
+            LOG.error("Dispatcher initialization failed", ex);
             throw new StrutsException(ex);
         }
     }
@@ -591,7 +586,7 @@ public class Dispatcher {
             uri = uri + "?" + request.getQueryString();
         }
         if (devMode) {
-            LOG.error("Could not find action or result\n{}", uri, e);
+            LOG.error("Could not find action or result: {}", uri, e);
         } else if (LOG.isWarnEnabled()) {
             LOG.warn("Could not find action or result: {}", uri, e);
         }
@@ -675,7 +670,7 @@ public class Dispatcher {
                                     Map applicationMap,
                                     HttpServletRequest request,
                                     HttpServletResponse response) {
-        HashMap<String,Object> extraContext = new HashMap<String,Object>();
+        HashMap<String, Object> extraContext = new HashMap<>();
         extraContext.put(ActionContext.PARAMETERS, new HashMap(parameterMap));
         extraContext.put(ActionContext.SESSION, sessionMap);
         extraContext.put(ActionContext.APPLICATION, applicationMap);
@@ -715,9 +710,7 @@ public class Dispatcher {
 
         if (saveDir.equals("")) {
             File tempdir = (File) servletContext.getAttribute("javax.servlet.context.tempdir");
-            if (LOG.isInfoEnabled()) {
         	LOG.info("Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir");
-            }
 
             if (tempdir != null) {
                 saveDir = tempdir.toString();
@@ -737,17 +730,13 @@ public class Dispatcher {
                     if (devMode) {
                         LOG.error(logMessage);
                     } else {
-                        if (LOG.isWarnEnabled()) {
-                            LOG.warn(logMessage);
-                        }
+                        LOG.warn(logMessage);
                     }
                 }
             }
         }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("saveDir=" + saveDir);
-        }
+        LOG.debug("saveDir={}", saveDir);
 
         return saveDir;
     }
@@ -794,7 +783,7 @@ public class Dispatcher {
                 request.setCharacterEncoding(encoding);
             }
         } catch (Exception e) {
-            LOG.error("Error setting character encoding to '" + encoding + "' - ignoring.", e);
+            LOG.error("Error setting character encoding to '{}' - ignoring.", encoding, e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
index 6fbbd0b..210451f 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
@@ -170,7 +170,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
     /**
      * Maintains per-request override of devMode configuration.
      */
-    private static ThreadLocal<Boolean> devModeOverride = new InheritableThreadLocal<Boolean>();
+    private static ThreadLocal<Boolean> devModeOverride = new InheritableThreadLocal<>();
 
     /**
      * Initializes the filter by creating a default dispatcher
@@ -226,7 +226,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
      */
     public void destroy() {
         if (dispatcher == null) {
-            log.warn("something is seriously wrong, Dispatcher is not initialized (null) ");
+            log.warn("something is seriously wrong, Dispatcher is not initialized (null)");
         } else {
             try {
                 dispatcher.cleanup();
@@ -243,10 +243,8 @@ public class FilterDispatcher implements StrutsStatics, Filter {
      * 
      * @param devMode   the override value
      */
-    public static void overrideDevMode(
-        boolean devMode)
-    {
-        devModeOverride.set(Boolean.valueOf(devMode));
+    public static void overrideDevMode(boolean devMode) {
+        devModeOverride.set(devMode);
     }
 
     /**
@@ -265,7 +263,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
      * @return Initialized Dispatcher
      */
     protected Dispatcher createDispatcher(FilterConfig filterConfig) {
-        Map<String, String> params = new HashMap<String, String>();
+        Map<String, String> params = new HashMap<>();
         for (Enumeration e = filterConfig.getInitParameterNames(); e.hasMoreElements();) {
             String name = (String) e.nextElement();
             String value = filterConfig.getInitParameter(name);

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java b/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java
index d25772b..3613502 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java
@@ -26,8 +26,8 @@ import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.Result;
 import com.opensymphony.xwork2.util.TextParseUtil;
 import com.opensymphony.xwork2.util.ValueStack;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.ServletActionContext;
 
 import javax.servlet.http.HttpServletResponse;
@@ -83,7 +83,7 @@ public class HttpHeaderResult implements Result {
     private static final Logger LOG = LogManager.getLogger(HttpHeaderResult.class);
 
     /**
-     * This result type doesn't have a default param, null is ok to reduce noice in logs
+     * This result type doesn't have a default param, null is ok to reduce noise in logs
      */
     public static final String DEFAULT_PARAM = null;
 
@@ -95,7 +95,7 @@ public class HttpHeaderResult implements Result {
 
     public HttpHeaderResult() {
         super();
-        headers = new HashMap<String, String>();
+        headers = new HashMap<>();
     }
 
     public HttpHeaderResult(int status) {
@@ -195,9 +195,7 @@ public class HttpHeaderResult implements Result {
             try {
                 errorCode = Integer.parseInt(parse ? TextParseUtil.translateVariables(error, stack) : error);
             } catch (Exception e) {
-                if (LOG.isErrorEnabled()) {
-                    LOG.error("Cannot parse errorCode [{}] value as Integer!", error, e);
-                }
+                LOG.error("Cannot parse errorCode [{}] value as Integer!", error, e);
             }
             if (errorCode != -1) {
                 if (errorMessage != null) {

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java b/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java
index 38259eb..c27e078 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java
@@ -22,8 +22,8 @@
 package org.apache.struts2.dispatcher;
 
 import com.opensymphony.xwork2.ActionInvocation;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletResponse;
@@ -132,9 +132,7 @@ public class PlainTextResult extends StrutsResultSupport {
             } else {
                 reader = new InputStreamReader(resourceAsStream);
             }
-            if (resourceAsStream != null) {
-                sendStream(writer, reader);
-            }
+            sendStream(writer, reader);
         } finally {
             if (reader != null)
                 reader.close();
@@ -152,9 +150,7 @@ public class PlainTextResult extends StrutsResultSupport {
 
     protected void logWrongStream(String finalLocation, InputStream resourceAsStream) {
         if (resourceAsStream == null) {
-            if (LOG.isWarnEnabled()) {
-                LOG.warn("Resource at location [" + finalLocation + "] cannot be obtained (return null) from ServletContext !!! ");
-            }
+            LOG.warn("Resource at location [{}] cannot be obtained (return null) from ServletContext !!!", finalLocation);
         }
     }
 
@@ -191,13 +187,10 @@ public class PlainTextResult extends StrutsResultSupport {
             if (Charset.isSupported(charSet)) {
                 charset = Charset.forName(charSet);
             } else {
-                if (LOG.isWarnEnabled()) {
-                    LOG.warn("charset [" + charSet + "] is not recognized ");
-                }
+                LOG.warn("charset [{}] is not recognized", charset);
                 charset = null;
             }
         }
         return charset;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java b/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
index 86443f1..b8392ba 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
@@ -39,7 +39,6 @@ public class RequestMap extends AbstractMap implements Serializable {
     private Set<Object> entries;
     private HttpServletRequest request;
 
-
     /**
      * Saves the request to use as the backing for getting and setting values
      *
@@ -70,7 +69,7 @@ public class RequestMap extends AbstractMap implements Serializable {
      */
     public Set entrySet() {
         if (entries == null) {
-            entries = new HashSet<Object>();
+            entries = new HashSet<>();
 
             Enumeration enumeration = request.getAttributeNames();
 

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/ServletDispatcherResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ServletDispatcherResult.java b/core/src/main/java/org/apache/struts2/dispatcher/ServletDispatcherResult.java
index 6cd5eb1..52d4f67 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/ServletDispatcherResult.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletDispatcherResult.java
@@ -23,10 +23,10 @@ package org.apache.struts2.dispatcher;
 
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.inject.Inject;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsStatics;
 import org.apache.struts2.views.util.UrlHelper;
@@ -122,9 +122,7 @@ public class ServletDispatcherResult extends StrutsResultSupport {
      *                   HTTP request.
      */
     public void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Forwarding to location " + finalLocation);
-        }
+        LOG.debug("Forwarding to location: {}", finalLocation);
 
         PageContext pageContext = ServletActionContext.getPageContext();
 

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
index 9476221..99317f3 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
@@ -25,10 +25,10 @@ import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.config.entities.ResultConfig;
 import com.opensymphony.xwork2.inject.Inject;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
 import com.opensymphony.xwork2.util.reflection.ReflectionException;
 import com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.dispatcher.mapper.ActionMapper;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
@@ -106,7 +106,7 @@ public class ServletRedirectResult extends StrutsResultSupport implements Reflec
     protected ActionMapper actionMapper;
     protected int statusCode = SC_FOUND;
     protected boolean suppressEmptyParameters = false;
-    protected Map<String, Object> requestParameters = new LinkedHashMap<String, Object>();
+    protected Map<String, Object> requestParameters = new LinkedHashMap<>();
     protected String anchor;
 
     private UrlHelper urlHelper;
@@ -221,10 +221,8 @@ public class ServletRedirectResult extends StrutsResultSupport implements Reflec
         }
 
         finalLocation = response.encodeRedirectURL(tmpLocation.toString());
- 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Redirecting to finalLocation " + finalLocation);
-        }
+
+        LOG.debug("Redirecting to finalLocation: {}", finalLocation);
 
         sendRedirect(response, finalLocation);
     }

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java b/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
index 8da98da..73ff87e 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
@@ -21,17 +21,10 @@
 
 package org.apache.struts2.dispatcher;
 
-import org.apache.struts2.components.Submit;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 import java.io.Serializable;
-import java.util.AbstractMap;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 
 /**
@@ -110,9 +103,9 @@ public class SessionMap<K, V> extends AbstractMap<K, V> implements Serializable
 
         synchronized (session.getId().intern()) {
             if (entries == null) {
-                entries = new HashSet<Map.Entry<K, V>>();
+                entries = new HashSet<>();
 
-                Enumeration<? extends Object> enumeration = session.getAttributeNames();
+                Enumeration<?> enumeration = session.getAttributeNames();
 
                 while (enumeration.hasMoreElements()) {
                     final String key = enumeration.nextElement().toString();

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java b/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java
index 05236ec..13a5c3c 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java
@@ -21,15 +21,14 @@
 
 package org.apache.struts2.dispatcher;
 
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.servlet.http.HttpServletResponse;
-
 import com.opensymphony.xwork2.ActionInvocation;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
 import com.opensymphony.xwork2.util.ValueStack;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.io.OutputStream;
 
 /**
  * <!-- START SNIPPET: description -->
@@ -259,9 +258,7 @@ public class StreamResult extends StrutsResultSupport {
                     }
                 }
                 catch(NumberFormatException e) {
-                    if (LOG.isWarnEnabled()) {
-                	LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e);
-                    }
+                    LOG.warn("failed to recognize {} as a number, contentLength header will not be set", _contentLength, e);
                 }
             }
 
@@ -279,24 +276,18 @@ public class StreamResult extends StrutsResultSupport {
             // Get the outputstream
             oOutput = oResponse.getOutputStream();
 
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Streaming result [" + inputName + "] type=[" + contentType + "] length=[" + contentLength +
-                    "] content-disposition=[" + contentDisposition + "] charset=[" + contentCharSet + "]");
-            }
+            LOG.debug("Streaming result [{}] type=[{}] length=[{}] content-disposition=[{}] charset=[{}]",
+                    inputName, contentType, contentLength, contentDisposition, contentCharSet);
 
             // Copy input to output
-            if (LOG.isDebugEnabled()) {
         	LOG.debug("Streaming to output buffer +++ START +++");
-            }
             byte[] oBuff = new byte[bufferSize];
             int iSize;
             while (-1 != (iSize = inputStream.read(oBuff))) {
                 oOutput.write(oBuff, 0, iSize);
             }
-            if (LOG.isDebugEnabled()) {
         	LOG.debug("Streaming to output buffer +++ END +++");
-            }
-            
+
             // Flush
             oOutput.flush();
         }
@@ -334,7 +325,7 @@ public class StreamResult extends StrutsResultSupport {
 
         Integer bufferSize = (Integer) stack.findValue("bufferSize", Integer.class);
         if (bufferSize != null) {
-            setBufferSize(bufferSize.intValue());
+            setBufferSize(bufferSize);
         }
 
         if (contentCharSet != null ) {

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java b/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java
index b7d57ba..f8f4ee1 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java
@@ -21,18 +21,17 @@
 
 package org.apache.struts2.dispatcher;
 
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.apache.struts2.StrutsStatics;
-
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.Result;
 import com.opensymphony.xwork2.util.TextParseUtil;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsStatics;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Collection;
 
 
 /**
@@ -227,7 +226,7 @@ public abstract class StrutsResultSupport implements Result, StrutsStatics {
                 excludeEmptyElements,
                 new EncodingParsedValueEvaluator());
         } else {
-            Collection<String> collection = new ArrayList<String>(1);
+            Collection<String> collection = new ArrayList<>(1);
             collection.add(param);
             return collection;
         }
@@ -246,9 +245,7 @@ public abstract class StrutsResultSupport implements Result, StrutsStatics {
                         return URLEncoder.encode(parsedValue, DEFAULT_URL_ENCODING);
                     }
                     catch(UnsupportedEncodingException e) {
-                        if (LOG.isWarnEnabled()) {
-                            LOG.warn("error while trying to encode ["+parsedValue+"]", e);
-                        }
+                        LOG.warn("error while trying to encode [{}]", parsedValue, e);
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java b/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java
index e16bb81..ff9d9df 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java
@@ -25,8 +25,8 @@ import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.views.JspSupportServlet;
@@ -159,7 +159,7 @@ public class VelocityResult extends StrutsResultSupport {
             // to do it all the time (WW-829). Since Velocity support is being deprecated, we'll oblige :)
             writer.flush();
         } catch (Exception e) {
-            LOG.error("Unable to render Velocity Template, '{}'", finalLocation, e);
+            LOG.error("Unable to render velocity template: '{}'", finalLocation, e);
             throw e;
         } finally {
             if (usedJspFactory) {

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapper.java b/core/src/main/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapper.java
index a648590..eaac291 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapper.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapper.java
@@ -24,6 +24,7 @@ package org.apache.struts2.dispatcher.mapper;
 import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.Inject;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.struts2.StrutsConstants;
@@ -49,18 +50,16 @@ public class CompositeActionMapper implements ActionMapper {
 
     private static final Logger LOG = LogManager.getLogger(CompositeActionMapper.class);
 
-    protected List<ActionMapper> actionMappers = new LinkedList<ActionMapper>();
+    protected List<ActionMapper> actionMappers = new LinkedList<>();
 
     @Inject
     public CompositeActionMapper(Container container,
                                  @Inject(value = StrutsConstants.STRUTS_MAPPER_COMPOSITE) String list) {
-        if (list != null) {
-            String[] arr = list.split(",");
-            for (String name : arr) {
-                Object obj = container.getInstance(ActionMapper.class, name);
-                if (obj != null) {
-                    actionMappers.add((ActionMapper) obj);
-                }
+        String[] arr = StringUtils.split(StringUtils.trimToEmpty(list), ",");
+        for (String name : arr) {
+            Object obj = container.getInstance(ActionMapper.class, name);
+            if (obj != null) {
+                actionMappers.add((ActionMapper) obj);
             }
         }
     }
@@ -69,21 +68,15 @@ public class CompositeActionMapper implements ActionMapper {
 
         for (ActionMapper actionMapper : actionMappers) {
             ActionMapping actionMapping = actionMapper.getMapping(request, configManager);
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Using ActionMapper "+actionMapper);
-            }
+            LOG.debug("Using ActionMapper: {}", actionMapper);
             if (actionMapping == null) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("ActionMapper "+actionMapper+" failed to return an ActionMapping (null)");
-                }
+                LOG.debug("ActionMapper {} failed to return an ActionMapping (null)", actionMapper);
             }
             else {
                 return actionMapping;
             }
         }
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("exhausted from ActionMapper that could return an ActionMapping");
-        }
+        LOG.debug("exhausted from ActionMapper that could return an ActionMapping");
         return null;
     }
 
@@ -91,21 +84,15 @@ public class CompositeActionMapper implements ActionMapper {
 
         for (ActionMapper actionMapper : actionMappers) {
             ActionMapping actionMapping = actionMapper.getMappingFromActionName(actionName);
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Using ActionMapper "+actionMapper);
-            }
+            LOG.debug("Using ActionMapper: {}", actionMapper);
             if (actionMapping == null) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("ActionMapper "+actionMapper+" failed to return an ActionMapping (null)");
-                }
+                LOG.debug("ActionMapper {} failed to return an ActionMapping (null)", actionMapper);
             }
             else {
                 return actionMapping;
             }
         }
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("exhausted from ActionMapper that could return an ActionMapping");
-        }
+        LOG.debug("exhausted from ActionMapper that could return an ActionMapping");
         return null;
     }
 
@@ -113,21 +100,15 @@ public class CompositeActionMapper implements ActionMapper {
 
         for (ActionMapper actionMapper : actionMappers) {
             String uri = actionMapper.getUriFromActionMapping(mapping);
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Using ActionMapper "+actionMapper);
-            }
+            LOG.debug("Using ActionMapper: {}", actionMapper);
             if (uri == null) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("ActionMapper "+actionMapper+" failed to return an ActionMapping (null)");
-                }
+                LOG.debug("ActionMapper {} failed to return an ActionMapping (null)", actionMapper);
             }
             else {
                 return uri;
             }
         }
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("exhausted from ActionMapper that could return a uri");
-        }
+        LOG.debug("exhausted from ActionMapper that could return an ActionMapping");
         return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java b/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
index 03c7ac5..5115b68 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
@@ -27,21 +27,17 @@ import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.config.entities.PackageConfig;
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.Inject;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
+import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.RequestUtils;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.util.PrefixTrie;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.regex.Pattern;
 
 /**
@@ -185,18 +181,18 @@ public class DefaultActionMapper implements ActionMapper {
     }
 
     @Inject(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION)
-    public void setAllowDynamicMethodCalls(String allow) {
-        allowDynamicMethodCalls = "true".equalsIgnoreCase(allow);
+    public void setAllowDynamicMethodCalls(String enableDynamicMethodCalls) {
+        this.allowDynamicMethodCalls = BooleanUtils.toBoolean(enableDynamicMethodCalls);
     }
 
     @Inject(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES)
-    public void setSlashesInActionNames(String allow) {
-        allowSlashesInActionNames = "true".equals(allow);
+    public void setSlashesInActionNames(String enableSlashesInActionNames) {
+        this.allowSlashesInActionNames = BooleanUtils.toBoolean(enableSlashesInActionNames);
     }
 
     @Inject(StrutsConstants.STRUTS_ALWAYS_SELECT_FULL_NAMESPACE)
-    public void setAlwaysSelectFullNamespace(String val) {
-        this.alwaysSelectFullNamespace = "true".equals(val);
+    public void setAlwaysSelectFullNamespace(String alwaysSelectFullNamespace) {
+        this.alwaysSelectFullNamespace = BooleanUtils.toBoolean(alwaysSelectFullNamespace);
     }
 
     @Inject(value = StrutsConstants.STRUTS_ALLOWED_ACTION_NAMES, required = false)
@@ -206,12 +202,12 @@ public class DefaultActionMapper implements ActionMapper {
 
     @Inject(value = StrutsConstants.STRUTS_MAPPER_ACTION_PREFIX_ENABLED)
     public void setAllowActionPrefix(String allowActionPrefix) {
-        this.allowActionPrefix = "true".equalsIgnoreCase(allowActionPrefix);
+        this.allowActionPrefix = BooleanUtils.toBoolean(allowActionPrefix);
     }
 
     @Inject(value = StrutsConstants.STRUTS_MAPPER_ACTION_PREFIX_CROSSNAMESPACES)
     public void setAllowActionCrossNamespaceAccess(String allowActionCrossNamespaceAccess) {
-        this.allowActionCrossNamespaceAccess = "true".equalsIgnoreCase(allowActionCrossNamespaceAccess);
+        this.allowActionCrossNamespaceAccess = BooleanUtils.toBoolean(allowActionCrossNamespaceAccess);
     }
 
     @Inject
@@ -221,8 +217,8 @@ public class DefaultActionMapper implements ActionMapper {
 
     @Inject(StrutsConstants.STRUTS_ACTION_EXTENSION)
     public void setExtensions(String extensions) {
-        if (extensions != null && !"".equals(extensions)) {
-            List<String> list = new ArrayList<String>();
+        if (StringUtils.isNotEmpty(extensions)) {
+            List<String> list = new ArrayList<>();
             String[] tokens = extensions.split(",");
             Collections.addAll(list, tokens);
             if (extensions.endsWith(",")) {
@@ -292,7 +288,7 @@ public class DefaultActionMapper implements ActionMapper {
      */
     public void handleSpecialParameters(HttpServletRequest request, ActionMapping mapping) {
         // handle special parameter prefixes.
-        Set<String> uniqueParameters = new HashSet<String>();
+        Set<String> uniqueParameters = new HashSet<>();
         Map parameterMap = request.getParameterMap();
         for (Object o : parameterMap.keySet()) {
             String key = (String) o;

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/mapper/PrefixBasedActionMapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/mapper/PrefixBasedActionMapper.java b/core/src/main/java/org/apache/struts2/dispatcher/mapper/PrefixBasedActionMapper.java
index b0adc3d..2ecccb5 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/mapper/PrefixBasedActionMapper.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/mapper/PrefixBasedActionMapper.java
@@ -3,8 +3,9 @@ package org.apache.struts2.dispatcher.mapper;
 import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.Inject;
-import org.apache.logging.log4j.Logger;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.RequestUtils;
 import org.apache.struts2.StrutsConstants;
 
@@ -44,7 +45,7 @@ public class PrefixBasedActionMapper extends DefaultActionMapper implements Acti
     private static final Logger LOG = LogManager.getLogger(PrefixBasedActionMapper.class);
 
     protected Container container;
-    protected Map<String, ActionMapper> actionMappers = new HashMap<String, ActionMapper>();
+    protected Map<String, ActionMapper> actionMappers = new HashMap<>();
 
     @Inject
     public void setContainer(Container container) {
@@ -53,19 +54,17 @@ public class PrefixBasedActionMapper extends DefaultActionMapper implements Acti
 
     @Inject(StrutsConstants.PREFIX_BASED_MAPPER_CONFIGURATION)
     public void setPrefixBasedActionMappers(String list) {
-        if (list != null) {
-            String[] mappers = list.split(",");
-            for (String mapper : mappers) {
-                String[] thisMapper = mapper.split(":");
-                if ((thisMapper != null) && (thisMapper.length == 2)) {
-                    String mapperPrefix = thisMapper[0].trim();
-                    String mapperName = thisMapper[1].trim();
-                    Object obj = container.getInstance(ActionMapper.class, mapperName);
-                    if (obj != null) {
-                        actionMappers.put(mapperPrefix, (ActionMapper) obj);
-                    } else {
-                        LOG.debug("invalid PrefixBasedActionMapper config entry: [{}]", mapper);
-                    }
+        String[] mappers = StringUtils.split(StringUtils.trimToEmpty(list), ",");
+        for (String mapper : mappers) {
+            String[] thisMapper = mapper.split(":");
+            if (thisMapper.length == 2) {
+                String mapperPrefix = thisMapper[0].trim();
+                String mapperName = thisMapper[1].trim();
+                Object obj = container.getInstance(ActionMapper.class, mapperName);
+                if (obj != null) {
+                    actionMappers.put(mapperPrefix, (ActionMapper) obj);
+                } else {
+                    LOG.debug("invalid PrefixBasedActionMapper config entry: [{}]", mapper);
                 }
             }
         }
@@ -104,9 +103,7 @@ public class PrefixBasedActionMapper extends DefaultActionMapper implements Acti
                 }
             }
         }
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("No ActionMapper found");
-        }
+        LOG.debug("No ActionMapper found");
         return null;
     }
 
@@ -124,9 +121,7 @@ public class PrefixBasedActionMapper extends DefaultActionMapper implements Acti
                 }
             }
         }
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("ActionMapper failed to return a uri");
-        }
+        LOG.debug("ActionMapper failed to return a uri");
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java b/core/src/main/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java
index 996d257..b474913 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java
@@ -23,6 +23,7 @@ package org.apache.struts2.dispatcher.mapper;
 
 import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.inject.Inject;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.struts2.StrutsConstants;
@@ -62,18 +63,16 @@ public class Restful2ActionMapper extends DefaultActionMapper {
         }
 
         String actionName = mapping.getName();
-
         String id = null;
 
         // Only try something if the action name is specified
-        if (actionName != null && actionName.length() > 0) {
+        if (StringUtils.isNotBlank(actionName)) {
 
             int lastSlashPos = actionName.lastIndexOf('/');
             if (lastSlashPos > -1) {
                 id = actionName.substring(lastSlashPos+1);
             }
 
-
             // If a method hasn't been explicitly named, try to guess using ReST-style patterns
             if (mapping.getMethod() == null) {
 
@@ -124,7 +123,7 @@ public class Restful2ActionMapper extends DefaultActionMapper {
             int actionSlashPos = actionName.lastIndexOf('/', lastSlashPos - 1);
             if (actionSlashPos > 0 && actionSlashPos < lastSlashPos) {
                 String params = actionName.substring(0, actionSlashPos);
-                HashMap<String,String> parameters = new HashMap<String,String>();
+                HashMap<String, String> parameters = new HashMap<>();
                 try {
                     StringTokenizer st = new StringTokenizer(params, "/");
                     boolean isNameTok = true;
@@ -152,9 +151,7 @@ public class Restful2ActionMapper extends DefaultActionMapper {
                         mapping.getParams().putAll(parameters);
                     }
                 } catch (Exception e) {
-                    if (LOG.isWarnEnabled()) {
                 	LOG.warn("Unable to determine parameters from the url", e);
-                    }
                 }
                 mapping.setName(actionName.substring(actionSlashPos+1));
             }

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java b/core/src/main/java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java
index 13ede87..d7ae2c0 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/mapper/RestfulActionMapper.java
@@ -52,7 +52,7 @@ public class RestfulActionMapper implements ActionMapper {
         }
 
         String actionName = uri.substring(1, nextSlash);
-        Map<String, Object> parameters = new HashMap<String, Object>();
+        Map<String, Object> parameters = new HashMap<>();
         try {
             StringTokenizer st = new StringTokenizer(uri.substring(nextSlash), "/");
             boolean isNameTok = true;
@@ -80,9 +80,7 @@ public class RestfulActionMapper implements ActionMapper {
                 }
             }
         } catch (Exception e) {
-            if (LOG.isWarnEnabled()) {
         	LOG.warn("Cannot determine url parameters", e);
-            }
         }
 
         return new ActionMapping(actionName, "", "", parameters);

http://git-wip-us.apache.org/repos/asf/struts/blob/e47a1127/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
index 635b420..e9ac67f 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
@@ -24,8 +24,6 @@ package org.apache.struts2.dispatcher.multipart;
 import com.opensymphony.xwork2.LocaleProvider;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.LocalizedTextUtil;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.FileUploadBase;
 import org.apache.commons.fileupload.FileUploadException;
@@ -33,6 +31,8 @@ import org.apache.commons.fileupload.RequestContext;
 import org.apache.commons.fileupload.disk.DiskFileItem;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.StrutsConstants;
 
 import javax.servlet.http.HttpServletRequest;
@@ -40,14 +40,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 /**
  * Multipart form data request adapter for Jakarta Commons Fileupload package.
@@ -57,13 +50,13 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
     static final Logger LOG = LogManager.getLogger(JakartaMultiPartRequest.class);
 
     // maps parameter name -> List of FileItem objects
-    protected Map<String, List<FileItem>> files = new HashMap<String, List<FileItem>>();
+    protected Map<String, List<FileItem>> files = new HashMap<>();
 
     // maps parameter name -> List of param values
-    protected Map<String, List<String>> params = new HashMap<String, List<String>>();
+    protected Map<String, List<String>> params = new HashMap<>();
 
     // any errors while processing this request
-    protected List<String> errors = new ArrayList<String>();
+    protected List<String> errors = new ArrayList<>();
 
     protected long maxSize;
     private Locale defaultLocale = Locale.ENGLISH;
@@ -91,17 +84,13 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
             setLocale(request);
             processUpload(request, saveDir);
         } catch (FileUploadBase.SizeLimitExceededException e) {
-            if (LOG.isWarnEnabled()) {
-                LOG.warn("Request exceeded size limit!", e);
-            }
+            LOG.warn("Request exceeded size limit!", e);
             String errorMessage = buildErrorMessage(e, new Object[]{e.getPermittedSize(), e.getActualSize()});
             if (!errors.contains(errorMessage)) {
                 errors.add(errorMessage);
             }
         } catch (Exception e) {
-            if (LOG.isWarnEnabled()) {
-                LOG.warn("Unable to parse request", e);
-            }
+            LOG.warn("Unable to parse request", e);
             String errorMessage = buildErrorMessage(e, new Object[]{});
             if (!errors.contains(errorMessage)) {
                 errors.add(errorMessage);
@@ -145,7 +134,7 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
         if (files.get(item.getFieldName()) != null) {
             values = files.get(item.getFieldName());
         } else {
-            values = new ArrayList<FileItem>();
+            values = new ArrayList<>();
         }
 
         values.add(item);
@@ -159,7 +148,7 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
         if (params.get(item.getFieldName()) != null) {
             values = params.get(item.getFieldName());
         } else {
-            values = new ArrayList<String>();
+            values = new ArrayList<>();
         }
 
         // note: see http://jira.opensymphony.com/browse/WW-633
@@ -214,7 +203,7 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
             return null;
         }
 
-        List<String> contentTypes = new ArrayList<String>(items.size());
+        List<String> contentTypes = new ArrayList<>(items.size());
         for (FileItem fileItem : items) {
             contentTypes.add(fileItem.getContentType());
         }
@@ -232,16 +221,14 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
             return null;
         }
 
-        List<File> fileList = new ArrayList<File>(items.size());
+        List<File> fileList = new ArrayList<>(items.size());
         for (FileItem fileItem : items) {
             File storeLocation = ((DiskFileItem) fileItem).getStoreLocation();
             if (fileItem.isInMemory() && storeLocation != null && !storeLocation.exists()) {
                 try {
                     storeLocation.createNewFile();
                 } catch (IOException e) {
-                    if (LOG.isErrorEnabled()) {
-                        LOG.error("Cannot write uploaded empty file to disk: " + storeLocation.getAbsolutePath(), e);
-                    }
+                    LOG.error("Cannot write uploaded empty file to disk: {}", storeLocation.getAbsolutePath(), e);
                 }
             }
             fileList.add(storeLocation);
@@ -260,7 +247,7 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
             return null;
         }
 
-        List<String> fileNames = new ArrayList<String>(items.size());
+        List<String> fileNames = new ArrayList<>(items.size());
         for (FileItem fileItem : items) {
             fileNames.add(getCanonicalName(fileItem.getName()));
         }
@@ -278,7 +265,7 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
             return null;
         }
 
-        List<String> fileNames = new ArrayList<String>(items.size());
+        List<String> fileNames = new ArrayList<>(items.size());
         for (FileItem fileItem : items) {
             fileNames.add(((DiskFileItem) fileItem).getStoreLocation().getName());
         }


Mime
View raw message