From 1219e49516ac2ecf4187cc80637e0924d10ebf84 Mon Sep 17 00:00:00 2001 From: Johannes Geppert Date: Tue, 3 May 2011 17:53:55 +0000 Subject: [PATCH] WW-3619: Check LogLevel for all debug, info and warning messages git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1099157 13f79535-47bb-0310-9956-ffa450edef68 --- .../struts2/components/ActionComponent.java | 4 ++- .../struts2/components/AppendIterator.java | 4 ++- .../org/apache/struts2/components/File.java | 8 ++++-- .../apache/struts2/components/Include.java | 8 ++++-- .../components/InputTransferSelect.java | 4 ++- .../struts2/components/MergeIterator.java | 4 ++- .../components/OptionTransferSelect.java | 4 ++- .../apache/struts2/components/Property.java | 4 ++- .../components/ServletUrlRenderer.java | 10 +++++-- .../org/apache/struts2/components/UIBean.java | 12 ++++++-- .../struts2/components/UpDownSelect.java | 4 ++- .../template/BaseTemplateEngine.java | 8 ++++-- .../struts2/config/BeanSelectionProvider.java | 10 +++++-- ...LegacyPropertiesConfigurationProvider.java | 4 ++- .../struts2/config/PropertiesSettings.java | 8 ++++-- .../apache/struts2/dispatcher/Dispatcher.java | 22 +++++++++++---- .../struts2/dispatcher/PlainTextResult.java | 8 ++++-- .../struts2/dispatcher/StreamResult.java | 14 +++++++--- .../dispatcher/StrutsResultSupport.java | 4 ++- .../mapper/Restful2ActionMapper.java | 4 ++- .../mapper/RestfulActionMapper.java | 4 ++- .../multipart/JakartaMultiPartRequest.java | 12 ++++++-- .../interceptor/CheckboxInterceptor.java | 4 ++- .../interceptor/ClearSessionInterceptor.java | 5 +++- .../interceptor/CookieInterceptor.java | 15 ++++++---- .../interceptor/CreateSessionInterceptor.java | 5 +++- .../ExecuteAndWaitInterceptor.java | 4 ++- .../interceptor/FileUploadInterceptor.java | 28 ++++++++++++++----- .../interceptor/MessageStoreInterceptor.java | 21 ++++++++++---- .../validation/JSONValidationInterceptor.java | 4 ++- .../struts2/util/IteratorGenerator.java | 4 ++- .../struts2/util/SubsetIteratorFilter.java | 4 ++- .../struts2/util/TextProviderHelper.java | 16 ++++++++--- .../org/apache/struts2/util/TokenHelper.java | 26 +++++++++++------ .../views/freemarker/FreemarkerManager.java | 4 ++- .../jsp/iterator/IteratorGeneratorTag.java | 4 ++- .../views/jsp/iterator/SubsetIteratorTag.java | 8 ++++-- .../apache/struts2/views/util/UrlHelper.java | 8 ++++-- .../views/velocity/VelocityManager.java | 12 ++++++-- .../apache/struts2/views/xslt/XSLTResult.java | 12 ++++++-- .../config_browser/ShowValidatorAction.java | 4 ++- .../jasperreports/JasperReportsResult.java | 8 ++++-- .../jasperreports/ValueStackDataSource.java | 12 ++++++-- .../views/java/JavaTemplateEngine.java | 5 ++-- .../org/apache/struts2/json/JSONCleaner.java | 4 ++- .../org/apache/struts2/json/JSONWriter.java | 4 ++- .../struts2/json/SerializationParams.java | 4 +-- .../apache/struts2/json/smd/SMDGenerator.java | 5 ++-- .../apache/struts2/osgi/FelixOsgiHost.java | 3 +- .../osgi/OsgiConfigurationProvider.java | 6 ++-- .../DefaultOValValidationManager.java | 8 ++++-- .../OValValidationInterceptor.java | 13 +++++++-- .../multipart/PellMultiPartRequest.java | 4 ++- .../apache/struts2/plexus/PlexusFilter.java | 4 ++- .../struts2/plexus/PlexusObjectFactory.java | 4 ++- .../apache/struts2/plexus/PlexusUtils.java | 4 ++- .../portlet/context/PreparatorServlet.java | 2 ++ .../context/ServletContextHolderListener.java | 4 ++- .../portlet/dispatcher/Jsr168Dispatcher.java | 9 ++++-- .../interceptor/PortletAwareInterceptor.java | 4 ++- .../portlet/util/PortletUrlHelper.java | 4 ++- .../struts2/rest/RestActionInvocation.java | 13 +++++---- .../apache/struts2/sitegraph/SiteGraph.java | 4 ++- .../sitegraph/entities/FileBasedView.java | 4 ++- ...lassReloadingXMLWebApplicationContext.java | 8 ++++-- .../spring/StrutsSpringObjectFactory.java | 12 ++++++-- .../struts2/tiles/StrutsTilesListener.java | 4 ++- .../opensymphony/xwork2/ActionSupport.java | 4 ++- .../xwork2/config/ConfigurationManager.java | 6 +++- .../config/impl/DefaultConfiguration.java | 2 +- .../config/providers/InterceptorBuilder.java | 8 ++++-- .../providers/XmlConfigurationProvider.java | 28 ++++++++++++++----- .../impl/DefaultObjectTypeDeterminer.java | 2 +- .../xwork2/interceptor/AliasInterceptor.java | 4 ++- .../interceptor/LoggingInterceptor.java | 4 ++- .../opensymphony/xwork2/ognl/OgnlUtil.java | 4 ++- .../XWorkCollectionPropertyAccessor.java | 14 ++++++++-- .../xwork2/spring/SpringObjectFactory.java | 20 +++++++++---- .../spring/SpringProxyableObjectFactory.java | 4 ++- .../ActionAutowiringInterceptor.java | 4 ++- .../opensymphony/xwork2/util/FileManager.java | 8 ++++-- .../xwork2/util/LocalizedTextUtil.java | 12 +++++--- .../xwork2/util/ResolverUtil.java | 16 ++++++++--- .../xwork2/util/profiling/UtilTimerStack.java | 8 ++++-- .../validator/DefaultValidatorFileParser.java | 4 ++- .../validator/ValidationInterceptor.java | 4 ++- ...eConversionErrorFieldValidatorSupport.java | 8 ++++-- 87 files changed, 491 insertions(+), 181 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/ActionComponent.java b/core/src/main/java/org/apache/struts2/components/ActionComponent.java index 03ec35461..5eb703563 100644 --- a/core/src/main/java/org/apache/struts2/components/ActionComponent.java +++ b/core/src/main/java/org/apache/struts2/components/ActionComponent.java @@ -167,7 +167,9 @@ public class ActionComponent extends ContextBean { try { writer.flush(); } catch (IOException e) { - LOG.warn("error while trying to flush writer ", e); + if (LOG.isWarnEnabled()) { + LOG.warn("error while trying to flush writer ", e); + } } } executeAction(); diff --git a/core/src/main/java/org/apache/struts2/components/AppendIterator.java b/core/src/main/java/org/apache/struts2/components/AppendIterator.java index a75049737..633fc0a0d 100644 --- a/core/src/main/java/org/apache/struts2/components/AppendIterator.java +++ b/core/src/main/java/org/apache/struts2/components/AppendIterator.java @@ -141,7 +141,9 @@ public class AppendIterator extends ContextBean implements UnnamedParametric { Object iteratorEntryObj = paramEntries.next(); if (! MakeIterator.isIterable(iteratorEntryObj)) { - LOG.warn("param with value resolved as "+iteratorEntryObj+" cannot be make as iterator, it will be ignored and hence will not appear in the merged iterator"); + if (LOG.isWarnEnabled()) { + LOG.warn("param with value resolved as "+iteratorEntryObj+" cannot be make as iterator, it will be ignored and hence will not appear in the merged iterator"); + } continue; } appendIteratorFilter.setSource(MakeIterator.convert(iteratorEntryObj)); diff --git a/core/src/main/java/org/apache/struts2/components/File.java b/core/src/main/java/org/apache/struts2/components/File.java index 8e781db2c..449ba1feb 100644 --- a/core/src/main/java/org/apache/struts2/components/File.java +++ b/core/src/main/java/org/apache/struts2/components/File.java @@ -75,13 +75,17 @@ public class File extends UIBean { String encType = (String) form.getParameters().get("enctype"); if (!"multipart/form-data".equals(encType)) { // uh oh, this isn't good! Let's warn the developer - LOG.warn("Struts has detected a file upload UI tag (s:file) being used without a form set to enctype 'multipart/form-data'. This is probably an error!"); + if (LOG.isWarnEnabled()) { + LOG.warn("Struts has detected a file upload UI tag (s:file) being used without a form set to enctype 'multipart/form-data'. This is probably an error!"); + } } String method = (String) form.getParameters().get("method"); if (!"post".equalsIgnoreCase(method)) { // uh oh, this isn't good! Let's warn the developer - LOG.warn("Struts has detected a file upload UI tag (s:file) being used without a form set to method 'POST'. This is probably an error!"); + if (LOG.isWarnEnabled()) { + LOG.warn("Struts has detected a file upload UI tag (s:file) being used without a form set to method 'POST'. This is probably an error!"); + } } } diff --git a/core/src/main/java/org/apache/struts2/components/Include.java b/core/src/main/java/org/apache/struts2/components/Include.java index ab1773e6d..9a918f097 100644 --- a/core/src/main/java/org/apache/struts2/components/Include.java +++ b/core/src/main/java/org/apache/struts2/components/Include.java @@ -150,7 +150,9 @@ public class Include extends Component { try { urlBuf.append(URLEncoder.encode(values.get(i).toString(), "UTF-8")); } catch (Exception e) { - LOG.warn("unable to url-encode "+values.get(i).toString()+", it will be ignored"); + if (LOG.isWarnEnabled()) { + LOG.warn("unable to url-encode "+values.get(i).toString()+", it will be ignored"); + } } concat = "&"; @@ -164,7 +166,9 @@ public class Include extends Component { try { include(result, writer, req, res, defaultEncoding); } catch (Exception e) { - LOG.warn("Exception thrown during include of " + result, e); + if (LOG.isWarnEnabled()) { + LOG.warn("Exception thrown during include of " + result, e); + } } return super.end(writer, body); diff --git a/core/src/main/java/org/apache/struts2/components/InputTransferSelect.java b/core/src/main/java/org/apache/struts2/components/InputTransferSelect.java index 4a157bc48..e5628fe24 100644 --- a/core/src/main/java/org/apache/struts2/components/InputTransferSelect.java +++ b/core/src/main/java/org/apache/struts2/components/InputTransferSelect.java @@ -201,7 +201,9 @@ public class InputTransferSelect extends ListUIBean { } else { - LOG.warn("form enclosing inputtransferselect "+this+" not found, auto select upon form submit of inputtransferselect will not work"); + if (LOG.isWarnEnabled()) { + LOG.warn("form enclosing inputtransferselect "+this+" not found, auto select upon form submit of inputtransferselect will not work"); + } } } diff --git a/core/src/main/java/org/apache/struts2/components/MergeIterator.java b/core/src/main/java/org/apache/struts2/components/MergeIterator.java index 2c11a2dae..a0c8c2ae4 100644 --- a/core/src/main/java/org/apache/struts2/components/MergeIterator.java +++ b/core/src/main/java/org/apache/struts2/components/MergeIterator.java @@ -155,7 +155,9 @@ public class MergeIterator extends ContextBean implements UnnamedParametric { for (Iterator parametersIterator = _parameters.iterator(); parametersIterator.hasNext(); ) { Object iteratorEntryObj = parametersIterator.next(); if (! MakeIterator.isIterable(iteratorEntryObj)) { - LOG.warn("param with value resolved as "+iteratorEntryObj+" cannot be make as iterator, it will be ignored and hence will not appear in the merged iterator"); + if (LOG.isWarnEnabled()) { + LOG.warn("param with value resolved as "+iteratorEntryObj+" cannot be make as iterator, it will be ignored and hence will not appear in the merged iterator"); + } continue; } mergeIteratorFilter.setSource(MakeIterator.convert(iteratorEntryObj)); diff --git a/core/src/main/java/org/apache/struts2/components/OptionTransferSelect.java b/core/src/main/java/org/apache/struts2/components/OptionTransferSelect.java index ac21020ba..7c0f41dec 100644 --- a/core/src/main/java/org/apache/struts2/components/OptionTransferSelect.java +++ b/core/src/main/java/org/apache/struts2/components/OptionTransferSelect.java @@ -332,7 +332,9 @@ public class OptionTransferSelect extends DoubleListUIBean { } else { - LOG.warn("form enclosing optiontransferselect "+this+" not found, auto select upon form submit of optiontransferselect will not work"); + if (LOG.isWarnEnabled()) { + LOG.warn("form enclosing optiontransferselect "+this+" not found, auto select upon form submit of optiontransferselect will not work"); + } } } diff --git a/core/src/main/java/org/apache/struts2/components/Property.java b/core/src/main/java/org/apache/struts2/components/Property.java index cce952071..821f54445 100644 --- a/core/src/main/java/org/apache/struts2/components/Property.java +++ b/core/src/main/java/org/apache/struts2/components/Property.java @@ -165,7 +165,9 @@ public class Property extends Component { writer.write(prepare(defaultValue)); } } catch (IOException e) { - LOG.info("Could not print out value '" + value + "'", e); + if (LOG.isInfoEnabled()) { + LOG.info("Could not print out value '" + value + "'", e); + } } return result; diff --git a/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java b/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java index 548a3b1a5..969e76a54 100644 --- a/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java +++ b/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java @@ -182,7 +182,7 @@ public class ServletUrlRenderer implements UrlRenderer { // Warn user that the specified namespace/action combo // was not found in the configuration. - if (namespace != null) { + if (namespace != null && LOG.isWarnEnabled()) { LOG.warn("No configuration found for the specified action: '" + actionName + "' in namespace: '" + namespace + "'. Form action defaulting to 'action' attribute's literal value."); } @@ -246,10 +246,14 @@ public class ServletUrlRenderer implements UrlRenderer { includeGetParameters(urlComponent); includeExtraParameters(urlComponent); } else if (includeParams != null) { - LOG.warn("Unknown value for includeParams parameter to URL tag: " + includeParams); + if (LOG.isWarnEnabled()) { + LOG.warn("Unknown value for includeParams parameter to URL tag: " + includeParams); + } } } catch (Exception e) { - LOG.warn("Unable to put request parameters (" + urlComponent.getHttpServletRequest().getQueryString() + ") into parameter map.", e); + if (LOG.isWarnEnabled()) { + LOG.warn("Unable to put request parameters (" + urlComponent.getHttpServletRequest().getQueryString() + ") into parameter map.", e); + } } diff --git a/core/src/main/java/org/apache/struts2/components/UIBean.java b/core/src/main/java/org/apache/struts2/components/UIBean.java index dbd98ff3e..24039d082 100644 --- a/core/src/main/java/org/apache/struts2/components/UIBean.java +++ b/core/src/main/java/org/apache/struts2/components/UIBean.java @@ -817,7 +817,9 @@ public abstract class UIBean extends Component { } } else { - LOG.warn("No ancestor Form found, javascript based tooltip will not work, however standard HTML tooltip using alt and title attribute will still work "); + if (LOG.isWarnEnabled()) { + LOG.warn("No ancestor Form found, javascript based tooltip will not work, however standard HTML tooltip using alt and title attribute will still work "); + } } //TODO: this is to keep backward compatibility, remove once when tooltipConfig is dropped @@ -902,7 +904,9 @@ public abstract class UIBean extends Component { if (form != null) { form.addParameter("customOnsubmitEnabled", Boolean.TRUE); } else { - LOG.warn("Cannot find an Ancestor form, custom onsubmit is NOT enabled"); + if (LOG.isWarnEnabled()) { + LOG.warn("Cannot find an Ancestor form, custom onsubmit is NOT enabled"); + } } } @@ -932,7 +936,9 @@ public abstract class UIBean extends Component { tooltipConfig.put(key, value); } else { - LOG.warn("component "+component+" tooltip config param "+key+" has no value defined, skipped"); + if (LOG.isWarnEnabled()) { + LOG.warn("component "+component+" tooltip config param "+key+" has no value defined, skipped"); + } } } } diff --git a/core/src/main/java/org/apache/struts2/components/UpDownSelect.java b/core/src/main/java/org/apache/struts2/components/UpDownSelect.java index f7c32bba3..af24bf936 100644 --- a/core/src/main/java/org/apache/struts2/components/UpDownSelect.java +++ b/core/src/main/java/org/apache/struts2/components/UpDownSelect.java @@ -156,7 +156,9 @@ public class UpDownSelect extends Select { ancestorForm.getParameters().put("updownselectIds", m); } else { - LOG.warn("no ancestor form found for updownselect "+this+", therefore autoselect of all elements upon form submission will not work "); + if (LOG.isWarnEnabled()) { + LOG.warn("no ancestor form found for updownselect "+this+", therefore autoselect of all elements upon form submission will not work "); + } } } diff --git a/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java b/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java index 4d358bc0e..b74e00021 100644 --- a/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java +++ b/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java @@ -102,7 +102,9 @@ public abstract class BaseTemplateEngine implements TemplateEngine { try { is.close(); } catch (IOException io) { - LOG.warn("Unable to close input stream", io); + if (LOG.isWarnEnabled()) { + LOG.warn("Unable to close input stream", io); + } } } @@ -122,7 +124,9 @@ public abstract class BaseTemplateEngine implements TemplateEngine { try { return createFileInputStream(propFile); } catch (FileNotFoundException e) { - LOG.warn("Unable to find file in filesystem [" + propFile.getAbsolutePath() + "]"); + if (LOG.isWarnEnabled()) { + LOG.warn("Unable to find file in filesystem [" + propFile.getAbsolutePath() + "]"); + } return null; } } diff --git a/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java b/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java index 1fa6bcdff..6366c0cd2 100644 --- a/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java +++ b/core/src/main/java/org/apache/struts2/config/BeanSelectionProvider.java @@ -251,7 +251,9 @@ public class BeanSelectionProvider implements ConfigurationProvider { while (customBundles.hasMoreTokens()) { String name = customBundles.nextToken(); try { - LOG.info("Loading global messages from " + name); + if (LOG.isInfoEnabled()) { + LOG.info("Loading global messages from " + name); + } LocalizedTextUtil.addDefaultResourceBundle(name); } catch (Exception e) { LOG.error("Could not find messages file " + name + ".properties. Skipping"); @@ -268,7 +270,7 @@ public class BeanSelectionProvider implements ConfigurationProvider { if (!builder.contains(type)) { String foundName = props.getProperty(key, DEFAULT_BEAN_NAME); if (builder.contains(type, foundName)) { - if (LOG.isDebugEnabled()) { + if (LOG.isInfoEnabled()) { LOG.info("Choosing bean ("+foundName+") for "+type); } builder.alias(type, foundName, Container.DEFAULT_NAME); @@ -296,7 +298,9 @@ public class BeanSelectionProvider implements ConfigurationProvider { } } } else { - LOG.warn("Unable to alias bean type "+type+", default mapping already assigned."); + if (LOG.isWarnEnabled()) { + LOG.warn("Unable to alias bean type "+type+", default mapping already assigned."); + } } } diff --git a/core/src/main/java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java b/core/src/main/java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java index 0fcb1e3d4..79262f039 100644 --- a/core/src/main/java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java +++ b/core/src/main/java/org/apache/struts2/config/LegacyPropertiesConfigurationProvider.java @@ -89,7 +89,9 @@ public class LegacyPropertiesConfigurationProvider implements ConfigurationProvi } locale = new Locale(lang, country); } else { - LOG.info("No locale define, substituting the default VM locale"); + if (LOG.isInfoEnabled()) { + LOG.info("No locale define, substituting the default VM locale"); + } locale = Locale.getDefault(); } } 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 1907d7d5b..16c1d1bc6 100644 --- a/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java +++ b/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java @@ -57,7 +57,9 @@ class PropertiesSettings extends Settings { URL settingsUrl = ClassLoaderUtils.getResource(name + ".properties", getClass()); if (settingsUrl == null) { - LOG.debug(name + ".properties missing"); + if (LOG.isDebugEnabled()) { + LOG.debug(name + ".properties missing"); + } settings = new LocatableProperties(); return; } @@ -76,7 +78,9 @@ class PropertiesSettings extends Settings { try { in.close(); } catch(IOException io) { - LOG.warn("Unable to close input stream", io); + if (LOG.isWarnEnabled()) { + LOG.warn("Unable to close input stream", io); + } } } } 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 515697c66..a846de528 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -258,7 +258,9 @@ public class Dispatcher { // clean up ObjectFactory ObjectFactory objectFactory = getContainer().getInstance(ObjectFactory.class); if (objectFactory == null) { - LOG.warn("Object Factory is null, something is seriously wrong, no clean up will be performed"); + if (LOG.isWarnEnabled()) { + LOG.warn("Object Factory is null, something is seriously wrong, no clean up will be performed"); + } } if (objectFactory instanceof ObjectFactoryDestroyable) { try { @@ -395,7 +397,9 @@ public class Dispatcher { // test whether param-access workaround needs to be enabled if (servletContext != null && servletContext.getServerInfo() != null && servletContext.getServerInfo().indexOf("WebLogic") >= 0) { - LOG.info("WebLogic server detected. Enabling Struts parameter access work-around."); + if (LOG.isInfoEnabled()) { + LOG.info("WebLogic server detected. Enabling Struts parameter access work-around."); + } paramsWorkaroundEnabled = true; } else { paramsWorkaroundEnabled = "true".equals(container.getInstance(String.class, @@ -512,7 +516,9 @@ public class Dispatcher { LOG.error("Could not find action or result\n" + reqStr, e); } else { + if (LOG.isWarnEnabled()) { LOG.warn("Could not find action or result", e); + } } sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); } catch (Exception e) { @@ -616,7 +622,9 @@ public class Dispatcher { if (saveDir.equals("")) { File tempdir = (File) servletContext.getAttribute("javax.servlet.context.tempdir"); - LOG.info("Unable to find 'struts.multipart.saveDir' property setting. Defaulting to 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(); @@ -637,7 +645,9 @@ public class Dispatcher { LOG.error(logMessage); } else { - LOG.warn(logMessage); + if (LOG.isWarnEnabled()) { + LOG.warn(logMessage); + } } } } @@ -754,7 +764,9 @@ public class Dispatcher { if ((currentFile != null) && currentFile.isFile()) { if (!currentFile.delete()) { - LOG.warn("Resource Leaking: Could not remove uploaded file '" + currentFile.getCanonicalPath() + "'."); + if (LOG.isWarnEnabled()) { + LOG.warn("Resource Leaking: Could not remove uploaded file '" + currentFile.getCanonicalPath() + "'."); + } } } } 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 406e74cce..939c2a161 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java @@ -120,7 +120,9 @@ public class PlainTextResult extends StrutsResultSupport { charset = Charset.forName(charSet); } else { - LOG.warn("charset ["+charSet+"] is not recognized "); + if (LOG.isWarnEnabled()) { + LOG.warn("charset ["+charSet+"] is not recognized "); + } charset = null; } } @@ -148,7 +150,9 @@ public class PlainTextResult extends StrutsResultSupport { reader = new InputStreamReader(resourceAsStream); } if (resourceAsStream == null) { - LOG.warn("resource at location ["+finalLocation+"] cannot be obtained (return null) from ServletContext !!! "); + if (LOG.isWarnEnabled()) { + LOG.warn("resource at location ["+finalLocation+"] cannot be obtained (return null) from ServletContext !!! "); + } } else { char[] buffer = new char[BUFFER_SIZE]; int charRead; 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 fe2f99488..66a17c95e 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java @@ -259,7 +259,9 @@ public class StreamResult extends StrutsResultSupport { } } catch(NumberFormatException e) { - LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e); + if (LOG.isWarnEnabled()) { + LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e); + } } } @@ -283,14 +285,18 @@ public class StreamResult extends StrutsResultSupport { } // Copy input to output - LOG.debug("Streaming to output buffer +++ START +++"); + 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); } - LOG.debug("Streaming to output buffer +++ END +++"); - + if (LOG.isDebugEnabled()) { + LOG.debug("Streaming to output buffer +++ END +++"); + } + // Flush oOutput.flush(); } 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 c934c68e9..16dfc16db 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java @@ -206,7 +206,9 @@ public abstract class StrutsResultSupport implements Result, StrutsStatics { return URLEncoder.encode(parsedValue.toString(), "UTF-8"); } catch(UnsupportedEncodingException e) { - LOG.warn("error while trying to encode ["+parsedValue+"]", e); + if (LOG.isWarnEnabled()) { + LOG.warn("error while trying to encode ["+parsedValue+"]", e); + } } } } 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 3312efd3c..573391461 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 @@ -210,7 +210,9 @@ public class Restful2ActionMapper extends DefaultActionMapper { mapping.getParams().putAll(parameters); } } catch (Exception e) { - LOG.warn("Unable to determine parameters from the url", e); + if (LOG.isWarnEnabled()) { + LOG.warn("Unable to determine parameters from the url", e); + } } mapping.setName(actionName.substring(actionSlashPos+1)); } 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 0eed0cd14..59f8eb813 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 @@ -106,7 +106,9 @@ public class RestfulActionMapper implements ActionMapper { } } } catch (Exception e) { - LOG.warn("Cannot determine url parameters", e); + if (LOG.isWarnEnabled()) { + LOG.warn("Cannot determine url parameters", e); + } } return new ActionMapping(actionName, "", "", parameters); 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 c95576729..45935694b 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 @@ -79,7 +79,9 @@ public class JakartaMultiPartRequest implements MultiPartRequest { try { processUpload(request, saveDir); } catch (FileUploadException e) { - LOG.warn("Unable to parse request", e); + if (LOG.isWarnEnabled()) { + LOG.warn("Unable to parse request", e); + } errors.add(e.getMessage()); } } @@ -98,7 +100,9 @@ public class JakartaMultiPartRequest implements MultiPartRequest { } private void processFileField(FileItem item) { - LOG.debug("Item is a file upload"); + if (LOG.isDebugEnabled()) { + LOG.debug("Item is a file upload"); + } // Skip file uploads that don't have a file name - meaning that no file was selected. if (item.getName() == null || item.getName().trim().length() < 1) { @@ -118,7 +122,9 @@ public class JakartaMultiPartRequest implements MultiPartRequest { } private void processNormalFormField(FileItem item, String charset) throws UnsupportedEncodingException { - LOG.debug("Item is a normal form field"); + if (LOG.isDebugEnabled()) { + LOG.debug("Item is a normal form field"); + } List values; if (params.get(item.getFieldName()) != null) { values = params.get(item.getFieldName()); diff --git a/core/src/main/java/org/apache/struts2/interceptor/CheckboxInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/CheckboxInterceptor.java index a267a5a08..0679dccc3 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/CheckboxInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/CheckboxInterceptor.java @@ -77,7 +77,9 @@ public class CheckboxInterceptor implements Interceptor { Object values = entry.getValue(); iterator.remove(); if (values != null && values instanceof String[] && ((String[])values).length > 1) { - LOG.debug("Bypassing automatic checkbox detection due to multiple checkboxes of the same name: #1", name); + if (LOG.isDebugEnabled()) { + LOG.debug("Bypassing automatic checkbox detection due to multiple checkboxes of the same name: #1", name); + } continue; } diff --git a/core/src/main/java/org/apache/struts2/interceptor/ClearSessionInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/ClearSessionInterceptor.java index b97eb6ed5..6e44570b8 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/ClearSessionInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/ClearSessionInterceptor.java @@ -83,7 +83,10 @@ public class ClearSessionInterceptor extends AbstractInterceptor { * @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation) */ public String intercept(ActionInvocation invocation) throws Exception { - LOG.debug("Clearing HttpSession"); + if (LOG.isDebugEnabled()) { + LOG.debug("Clearing HttpSession"); + } + ActionContext ac = invocation.getInvocationContext(); Map session = ac.getSession(); diff --git a/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java index 089d7579e..3f6b0d3fd 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java @@ -188,9 +188,10 @@ public class CookieInterceptor extends AbstractInterceptor { } public String intercept(ActionInvocation invocation) throws Exception { - if (LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) { LOG.debug("start interception"); - + } + // contains selected cookies final Map cookiesMap = new LinkedHashMap(); @@ -203,8 +204,9 @@ public class CookieInterceptor extends AbstractInterceptor { String value = cookie.getValue(); if (cookiesNameSet.contains("*")) { - if (LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) { LOG.debug("contains cookie name [*] in configured cookies name set, cookie with name [" + name + "] with value [" + value + "] will be injected"); + } populateCookieValueIntoStack(name, value, cookiesMap, stack); } else if (cookiesNameSet.contains(cookie.getName())) { populateCookieValueIntoStack(name, value, cookiesMap, stack); @@ -246,8 +248,10 @@ public class CookieInterceptor extends AbstractInterceptor { // if cookiesValues is specified, the cookie's value must match before we // inject them into Struts' action if (cookiesValueSet.contains(cookieValue)) { - if (LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) { LOG.debug("both configured cookie name and value matched, cookie ["+cookieName+"] with value ["+cookieValue+"] will be injected"); + } + cookiesMap.put(cookieName, cookieValue); stack.setValue(cookieName, cookieValue); } @@ -263,8 +267,9 @@ public class CookieInterceptor extends AbstractInterceptor { */ protected void injectIntoCookiesAwareAction(Object action, Map cookiesMap) { if (action instanceof CookiesAware) { - if (LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) { LOG.debug("action ["+action+"] implements CookiesAware, injecting cookies map ["+cookiesMap+"]"); + } ((CookiesAware)action).setCookiesMap(cookiesMap); } } diff --git a/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java index ce7eca1c9..cf803b5d5 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/CreateSessionInterceptor.java @@ -88,7 +88,10 @@ public class CreateSessionInterceptor extends AbstractInterceptor { * @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation) */ public String intercept(ActionInvocation invocation) throws Exception { - LOG.debug("Creating HttpSession"); + if (LOG.isDebugEnabled()) { + LOG.debug("Creating HttpSession"); + } + ServletActionContext.getRequest().getSession(true); return invocation.invoke(); } diff --git a/core/src/main/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java index bff2dd09d..210cf6f27 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptor.java @@ -263,10 +263,12 @@ public class ExecuteAndWaitInterceptor extends MethodFilterInterceptor { Map results = proxy.getConfig().getResults(); if (!results.containsKey(WAIT)) { - LOG.warn("ExecuteAndWait interceptor has detected that no result named 'wait' is available. " + + if (LOG.isWarnEnabled()) { + LOG.warn("ExecuteAndWait interceptor has detected that no result named 'wait' is available. " + "Defaulting to a plain built-in wait page. It is highly recommend you " + "provide an action-specific or global result named '" + WAIT + "'."); + } // no wait result? hmm -- let's try to do dynamically put it in for you! //we used to add a fake "wait" result here, since the configuration is unmodifiable, that is no longer diff --git a/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java index e1d282532..728cacd93 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java @@ -259,7 +259,9 @@ public class FileUploadInterceptor extends AbstractInterceptor { validation.addActionError(error); } - LOG.warn(error); + if (LOG.isWarnEnabled()) { + LOG.warn(error); + } } } @@ -303,10 +305,14 @@ public class FileUploadInterceptor extends AbstractInterceptor { } } } else { - LOG.warn(getTextMessage(action, "struts.messages.invalid.file", new Object[]{inputName}, ac.getLocale())); + if (LOG.isWarnEnabled()) { + LOG.warn(getTextMessage(action, "struts.messages.invalid.file", new Object[]{inputName}, ac.getLocale())); + } } } else { - LOG.warn(getTextMessage(action, "struts.messages.invalid.content.type", new Object[]{inputName}, ac.getLocale())); + if (LOG.isWarnEnabled()) { + LOG.warn(getTextMessage(action, "struts.messages.invalid.content.type", new Object[]{inputName}, ac.getLocale())); + } } } @@ -336,28 +342,36 @@ public class FileUploadInterceptor extends AbstractInterceptor { validation.addFieldError(inputName, errMsg); } - LOG.warn(errMsg); + if (LOG.isWarnEnabled()) { + LOG.warn(errMsg); + } } else if (maximumSize != null && maximumSize < file.length()) { String errMsg = getTextMessage(action, "struts.messages.error.file.too.large", new Object[]{inputName, filename, file.getName(), "" + file.length()}, locale); if (validation != null) { validation.addFieldError(inputName, errMsg); } - LOG.warn(errMsg); + if (LOG.isWarnEnabled()) { + LOG.warn(errMsg); + } } else if ((!allowedTypesSet.isEmpty()) && (!containsItem(allowedTypesSet, contentType))) { String errMsg = getTextMessage(action, "struts.messages.error.content.type.not.allowed", new Object[]{inputName, filename, file.getName(), contentType}, locale); if (validation != null) { validation.addFieldError(inputName, errMsg); } - LOG.warn(errMsg); + if (LOG.isWarnEnabled()) { + LOG.warn(errMsg); + } } else if ((!allowedExtensionsSet.isEmpty()) && (!hasAllowedExtension(allowedExtensionsSet, filename))) { String errMsg = getTextMessage(action, "struts.messages.error.file.extension.not.allowed", new Object[]{inputName, filename, file.getName(), contentType}, locale); if (validation != null) { validation.addFieldError(inputName, errMsg); } - LOG.warn(errMsg); + if (LOG.isWarnEnabled()) { + LOG.warn(errMsg); + } } else { fileIsAcceptable = true; } diff --git a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java index d6812051a..1407ae04c 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java @@ -198,13 +198,18 @@ public class MessageStoreInterceptor implements Interceptor { } public String intercept(ActionInvocation invocation) throws Exception { - LOG.debug("entering MessageStoreInterceptor ..."); + if (LOG.isDebugEnabled()) { + LOG.debug("entering MessageStoreInterceptor ..."); + } before(invocation); String result = invocation.invoke(); after(invocation, result); - LOG.debug("exit executing MessageStoreInterceptor"); + if (LOG.isDebugEnabled()) { + LOG.debug("exit executing MessageStoreInterceptor"); + } + return result; } @@ -228,7 +233,9 @@ public class MessageStoreInterceptor implements Interceptor { Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION); ValidationAware validationAwareAction = (ValidationAware) action; - LOG.debug("retrieve error / message from session to populate into action ["+action+"]"); + if (LOG.isDebugEnabled()) { + LOG.debug("retrieve error / message from session to populate into action ["+action+"]"); + } Collection actionErrors = (Collection) session.get(actionErrorsSessionKey); Collection actionMessages = (Collection) session.get(actionMessagesSessionKey); @@ -276,15 +283,17 @@ public class MessageStoreInterceptor implements Interceptor { // store error / messages into session Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION); - LOG.debug("store action ["+action+"] error/messages into session "); + if (LOG.isDebugEnabled()) { + LOG.debug("store action ["+action+"] error/messages into session "); + } ValidationAware validationAwareAction = (ValidationAware) action; session.put(actionErrorsSessionKey, validationAwareAction.getActionErrors()); session.put(actionMessagesSessionKey, validationAwareAction.getActionMessages()); session.put(fieldErrorsSessionKey, validationAwareAction.getFieldErrors()); } - else { - LOG.debug("Action ["+action+"] is not ValidationAware, no message / error that are storeable"); + else if(LOG.isDebugEnabled()) { + LOG.debug("Action ["+action+"] is not ValidationAware, no message / error that are storeable"); } } } diff --git a/core/src/main/java/org/apache/struts2/interceptor/validation/JSONValidationInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/validation/JSONValidationInterceptor.java index 4955a9034..1d1bec4d1 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/validation/JSONValidationInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/validation/JSONValidationInterceptor.java @@ -118,7 +118,9 @@ public class JSONValidationInterceptor extends MethodFilterInterceptor { private void setupEncoding(HttpServletResponse response, HttpServletRequest request) { if (isSetEncoding(request)) { - LOG.debug("Default encoding not set!"); + if (LOG.isDebugEnabled()) { + LOG.debug("Default encoding not set!"); + } } else { if (LOG.isDebugEnabled()) { LOG.debug("Setting up encoding to: [" + DEFAULT_ENCODING + "]!"); diff --git a/core/src/main/java/org/apache/struts2/util/IteratorGenerator.java b/core/src/main/java/org/apache/struts2/util/IteratorGenerator.java index 0fac95f71..a597d64de 100644 --- a/core/src/main/java/org/apache/struts2/util/IteratorGenerator.java +++ b/core/src/main/java/org/apache/struts2/util/IteratorGenerator.java @@ -93,7 +93,9 @@ public class IteratorGenerator implements Iterator, Action { values.add(convertedObj); } catch(Exception e) { // make sure things, goes on, we just ignore the bad ones - LOG.warn("unable to convert ["+token+"], skipping this token, it will not appear in the generated iterator", e); + if (LOG.isWarnEnabled()) { + LOG.warn("unable to convert ["+token+"], skipping this token, it will not appear in the generated iterator", e); + } } } else { diff --git a/core/src/main/java/org/apache/struts2/util/SubsetIteratorFilter.java b/core/src/main/java/org/apache/struts2/util/SubsetIteratorFilter.java index f12d653a8..61db5df57 100644 --- a/core/src/main/java/org/apache/struts2/util/SubsetIteratorFilter.java +++ b/core/src/main/java/org/apache/struts2/util/SubsetIteratorFilter.java @@ -167,7 +167,9 @@ public class SubsetIteratorFilter extends IteratorFilterSupport implements Itera return okToAdd; } catch(Exception e) { - LOG.warn("decider ["+decider+"] encountered an error while decide adding element ["+element+"], element will be ignored, it will not appeared in subseted iterator", e); + if (LOG.isWarnEnabled()) { + LOG.warn("decider ["+decider+"] encountered an error while decide adding element ["+element+"], element will be ignored, it will not appeared in subseted iterator", e); + } return false; } } diff --git a/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java b/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java index 075065879..0b50c0588 100644 --- a/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java +++ b/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java @@ -94,14 +94,22 @@ public class TextProviderHelper { if (LOG.isWarnEnabled()) { if (tp != null) { - LOG.warn("The first TextProvider in the ValueStack ("+tp.getClass().getName()+") could not locate the message resource with key '"+key+"'"); + if (LOG.isWarnEnabled()) { + LOG.warn("The first TextProvider in the ValueStack ("+tp.getClass().getName()+") could not locate the message resource with key '"+key+"'"); + } } else { - LOG.warn("Could not locate the message resource '"+key+"' as there is no TextProvider in the ValueStack."); + if (LOG.isWarnEnabled()) { + LOG.warn("Could not locate the message resource '"+key+"' as there is no TextProvider in the ValueStack."); + } } if (msg.equals(defaultMessage)) { - LOG.warn("The default value expression '"+defaultMessage+"' was evaluated and did not match a property. The literal value '"+defaultMessage+"' will be used."); + if (LOG.isWarnEnabled()) { + LOG.warn("The default value expression '"+defaultMessage+"' was evaluated and did not match a property. The literal value '"+defaultMessage+"' will be used."); + } } else { - LOG.warn("The default value expression '"+defaultMessage+"' evaluated to '"+msg+"'"); + if (LOG.isWarnEnabled()) { + LOG.warn("The default value expression '"+defaultMessage+"' evaluated to '"+msg+"'"); + } } } } diff --git a/core/src/main/java/org/apache/struts2/util/TokenHelper.java b/core/src/main/java/org/apache/struts2/util/TokenHelper.java index c10374509..3dd0ddb62 100644 --- a/core/src/main/java/org/apache/struts2/util/TokenHelper.java +++ b/core/src/main/java/org/apache/struts2/util/TokenHelper.java @@ -105,7 +105,9 @@ public class TokenHelper { String token; if ((tokens == null) || (tokens.length < 1)) { - LOG.warn("Could not find token mapped to token name " + tokenName); + if (LOG.isWarnEnabled()) { + LOG.warn("Could not find token mapped to token name " + tokenName); + } return null; } @@ -124,7 +126,9 @@ public class TokenHelper { Map params = ActionContext.getContext().getParameters(); if (!params.containsKey(TOKEN_NAME_FIELD)) { - LOG.warn("Could not find token name in params."); + if (LOG.isWarnEnabled()) { + LOG.warn("Could not find token name in params."); + } return null; } @@ -133,7 +137,9 @@ public class TokenHelper { String tokenName; if ((tokenNames == null) || (tokenNames.length < 1)) { - LOG.warn("Got a null or empty token name."); + if (LOG.isWarnEnabled()) { + LOG.warn("Got a null or empty token name."); + } return null; } @@ -153,16 +159,18 @@ public class TokenHelper { String tokenName = getTokenName(); if (tokenName == null) { - if (LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) { LOG.debug("no token name found -> Invalid token "); + } return false; } String token = getToken(tokenName); if (token == null) { - if (LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) { LOG.debug("no token found for token name "+tokenName+" -> Invalid token "); + } return false; } @@ -170,9 +178,11 @@ public class TokenHelper { String sessionToken = (String) session.get(tokenName); if (!token.equals(sessionToken)) { - LOG.warn(LocalizedTextUtil.findText(TokenHelper.class, "struts.internal.invalid.token", ActionContext.getContext().getLocale(), "Form token {0} does not match the session token {1}.", new Object[]{ - token, sessionToken - })); + if (LOG.isWarnEnabled()) { + LOG.warn(LocalizedTextUtil.findText(TokenHelper.class, "struts.internal.invalid.token", ActionContext.getContext().getLocale(), "Form token {0} does not match the session token {1}.", new Object[]{ + token, sessionToken + })); + } return false; } diff --git a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java index 24354a0c6..4bb4dcac1 100644 --- a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java +++ b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java @@ -450,7 +450,9 @@ public class FreemarkerManager { try { in.close(); } catch(IOException io) { - LOG.warn("Unable to close input stream", io); + if (LOG.isWarnEnabled()) { + LOG.warn("Unable to close input stream", io); + } } } } diff --git a/core/src/main/java/org/apache/struts2/views/jsp/iterator/IteratorGeneratorTag.java b/core/src/main/java/org/apache/struts2/views/jsp/iterator/IteratorGeneratorTag.java index 0aedb1beb..76371a9aa 100644 --- a/core/src/main/java/org/apache/struts2/views/jsp/iterator/IteratorGeneratorTag.java +++ b/core/src/main/java/org/apache/struts2/views/jsp/iterator/IteratorGeneratorTag.java @@ -206,7 +206,9 @@ public class IteratorGeneratorTag extends StrutsBodyTagSupport { count = Integer.parseInt((String)countObj); } catch(NumberFormatException e) { - LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); + if (LOG.isWarnEnabled()) { + LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); + } } } } diff --git a/core/src/main/java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java b/core/src/main/java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java index c0a8901f9..196b8b0c5 100644 --- a/core/src/main/java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java +++ b/core/src/main/java/org/apache/struts2/views/jsp/iterator/SubsetIteratorTag.java @@ -223,7 +223,9 @@ public class SubsetIteratorTag extends StrutsBodyTagSupport { count = Integer.parseInt((String)countObj); } catch(NumberFormatException e) { - LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); + if (LOG.isWarnEnabled()) { + LOG.warn("unable to convert count attribute ["+countObj+"] to number, ignore count attribute", e); + } } } } @@ -249,7 +251,9 @@ public class SubsetIteratorTag extends StrutsBodyTagSupport { start = Integer.parseInt((String)startObj); } catch(NumberFormatException e) { - LOG.warn("unable to convert count attribute ["+startObj+"] to number, ignore count attribute", e); + if (LOG.isWarnEnabled()) { + LOG.warn("unable to convert count attribute ["+startObj+"] to number, ignore count attribute", e); + } } } } diff --git a/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java b/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java index 6d707d803..055beaafc 100644 --- a/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java +++ b/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java @@ -266,7 +266,9 @@ public class UrlHelper { try { return URLEncoder.encode(translatedInput, encoding); } catch (UnsupportedEncodingException e) { - LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); + if (LOG.isWarnEnabled()) { + LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); + } return translatedInput; } } @@ -278,7 +280,9 @@ public class UrlHelper { try { return URLDecoder.decode(translatedInput, encoding); } catch (UnsupportedEncodingException e) { - LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); + if (LOG.isWarnEnabled()) { + LOG.warn("Could not encode URL parameter '" + input + "', returning value un-encoded"); + } return translatedInput; } } diff --git a/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java b/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java index a643920d9..445f6d2ab 100644 --- a/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java +++ b/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java @@ -192,7 +192,9 @@ public class VelocityManager { VelocityContext velocityContext = (VelocityContext) objectFactory.buildBean(className, null); contextList.add(velocityContext); } catch (Exception e) { - LOG.warn("Warning. " + e.getClass().getName() + " caught while attempting to instantiate a chained VelocityContext, " + className + " -- skipping"); + if (LOG.isWarnEnabled()) { + LOG.warn("Warning. " + e.getClass().getName() + " caught while attempting to instantiate a chained VelocityContext, " + className + " -- skipping"); + } } } if (contextList.size() > 0) { @@ -299,11 +301,15 @@ public class VelocityManager { // if we've got something, load 'er up if (in != null) { - LOG.info("Initializing velocity using " + resourceLocation); + if (LOG.isInfoEnabled()) { + LOG.info("Initializing velocity using " + resourceLocation); + } properties.load(in); } } catch (IOException e) { - LOG.warn("Unable to load velocity configuration " + resourceLocation, e); + if (LOG.isWarnEnabled()) { + LOG.warn("Unable to load velocity configuration " + resourceLocation, e); + } } finally { if (in != null) { try { diff --git a/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java b/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java index 79a1ec95a..08768e293 100644 --- a/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java +++ b/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java @@ -358,7 +358,9 @@ public class XSLTResult implements Result { public void warning(TransformerException exception) throws TransformerException { - LOG.warn(exception.getMessage(), exception); + if (LOG.isWarnEnabled()) { + LOG.warn(exception.getMessage(), exception); + } } }); @@ -384,7 +386,9 @@ public class XSLTResult implements Result { Source xmlSource = getDOMSourceForStack(result); // Transform the source XML to System.out. - LOG.debug("xmlSource = " + xmlSource); + if (LOG.isDebugEnabled()) { + LOG.debug("xmlSource = " + xmlSource); + } transformer.transform(xmlSource, new StreamResult(writer)); writer.flush(); // ...and flush... @@ -437,7 +441,9 @@ public class XSLTResult implements Result { throw new TransformerException("Stylesheet " + path + " not found in resources."); } - LOG.debug("Preparing XSLT stylesheet templates: " + path); + if (LOG.isDebugEnabled()) { + LOG.debug("Preparing XSLT stylesheet templates: " + path); + } TransformerFactory factory = TransformerFactory.newInstance(); factory.setURIResolver(getURIResolver()); diff --git a/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ShowValidatorAction.java b/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ShowValidatorAction.java index 0984e14b6..1669a980c 100644 --- a/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ShowValidatorAction.java +++ b/plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ShowValidatorAction.java @@ -112,7 +112,9 @@ public class ShowValidatorAction extends ListValidatorsAction { properties.add(new PropertyInfo(name, pd.getPropertyType(), value)); } } catch (Exception e) { - LOG.warn("Unable to retrieve properties.", e); + if (LOG.isWarnEnabled()) { + LOG.warn("Unable to retrieve properties.", e); + } addActionError("Unable to retrieve properties: " + e.toString()); } diff --git a/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/JasperReportsResult.java b/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/JasperReportsResult.java index 6dfd10414..4e6c8da6c 100644 --- a/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/JasperReportsResult.java +++ b/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/JasperReportsResult.java @@ -309,7 +309,9 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe // Add any report parameters from action to param map. Map reportParams = (Map) stack.findValue(reportParameters); if (reportParams != null) { - LOG.debug("Found report parameters; adding to parameters..."); + if (LOG.isDebugEnabled()) { + LOG.debug("Found report parameters; adding to parameters..."); + } parameters.putAll(reportParams); } @@ -382,7 +384,9 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe Map exportParams = (Map) stack.findValue(exportParameters); if (exportParams != null) { - LOG.debug("Found export parameters; adding to exporter parameters..."); + if (LOG.isDebugEnabled()) { + LOG.debug("Found export parameters; adding to exporter parameters..."); + } exporter.getParameters().putAll(exportParams); } diff --git a/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/ValueStackDataSource.java b/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/ValueStackDataSource.java index 347a69ef6..85ffa316d 100644 --- a/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/ValueStackDataSource.java +++ b/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/ValueStackDataSource.java @@ -70,7 +70,9 @@ public class ValueStackDataSource implements JRDataSource { iterator = MakeIterator.convert(array); } } else { - LOG.warn("Data source value for data source " + dataSource + " was null"); + if (LOG.isWarnEnabled()) { + LOG.warn("Data source value for data source " + dataSource + " was null"); + } } } @@ -128,11 +130,15 @@ public class ValueStackDataSource implements JRDataSource { if ((iterator != null) && (iterator.hasNext())) { valueStack.push(iterator.next()); - LOG.debug("Pushed next value: " + valueStack.findValue(".")); + if (LOG.isDebugEnabled()) { + LOG.debug("Pushed next value: " + valueStack.findValue(".")); + } return true; } else { - LOG.debug("No more values"); + if (LOG.isDebugEnabled()) { + LOG.debug("No more values"); + } return false; } diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateEngine.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateEngine.java index 72734ad2c..57b8eaf61 100644 --- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateEngine.java +++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateEngine.java @@ -86,8 +86,9 @@ public class JavaTemplateEngine extends BaseTemplateEngine { while (customThemes.hasMoreTokens()) { String themeClass = customThemes.nextToken().trim(); try { - LOG.info("Registering custom theme '" + themeClass + "' to javatemplates engine"); - + if (LOG.isInfoEnabled()) { + LOG.info("Registering custom theme '" + themeClass + "' to javatemplates engine"); + } //FIXME: This means Themes must have no-arg constructor - should use object factory here //ObjectFactory.getObjectFactory().buildBean(ClassLoaderUtil.loadClass(themeClass, getClass()), null); diff --git a/plugins/json/src/main/java/org/apache/struts2/json/JSONCleaner.java b/plugins/json/src/main/java/org/apache/struts2/json/JSONCleaner.java index 3ffcf9026..bb87c2f62 100644 --- a/plugins/json/src/main/java/org/apache/struts2/json/JSONCleaner.java +++ b/plugins/json/src/main/java/org/apache/struts2/json/JSONCleaner.java @@ -95,7 +95,9 @@ public abstract class JSONCleaner { if (allow(key)) { e.setValue(clean(key, e.getValue())); } else { - LOG.debug("blocked: " + key); + if (LOG.isDebugEnabled()) { + LOG.debug("blocked: " + key); + } iter.remove(); } } diff --git a/plugins/json/src/main/java/org/apache/struts2/json/JSONWriter.java b/plugins/json/src/main/java/org/apache/struts2/json/JSONWriter.java index df0fa5dd8..8e588843a 100644 --- a/plugins/json/src/main/java/org/apache/struts2/json/JSONWriter.java +++ b/plugins/json/src/main/java/org/apache/struts2/json/JSONWriter.java @@ -387,8 +387,10 @@ class JSONWriter { } hasData = true; if (!warnedNonString && !(key instanceof String)) { - LOG.warn("JavaScript doesn't support non-String keys, using toString() on " + if (LOG.isWarnEnabled()) { + LOG.warn("JavaScript doesn't support non-String keys, using toString() on " + key.getClass().getName()); + } warnedNonString = true; } this.value(key.toString(), method); diff --git a/plugins/json/src/main/java/org/apache/struts2/json/SerializationParams.java b/plugins/json/src/main/java/org/apache/struts2/json/SerializationParams.java index e9473e1ac..c1447a746 100644 --- a/plugins/json/src/main/java/org/apache/struts2/json/SerializationParams.java +++ b/plugins/json/src/main/java/org/apache/struts2/json/SerializationParams.java @@ -20,10 +20,10 @@ */ package org.apache.struts2.json; -import org.apache.commons.lang.StringUtils; - import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringUtils; + public class SerializationParams { private static final String DEFAULT_CONTENT_TYPE = "application/json"; diff --git a/plugins/json/src/main/java/org/apache/struts2/json/smd/SMDGenerator.java b/plugins/json/src/main/java/org/apache/struts2/json/smd/SMDGenerator.java index 75b3e4ba9..d4479b99d 100644 --- a/plugins/json/src/main/java/org/apache/struts2/json/smd/SMDGenerator.java +++ b/plugins/json/src/main/java/org/apache/struts2/json/smd/SMDGenerator.java @@ -69,9 +69,8 @@ public class SMDGenerator { // find params for this method processMethodsParameters(method, smdMethod); - } else { - if (LOG.isDebugEnabled()) - LOG.debug("Ignoring property " + method.getName()); + } else if(LOG.isDebugEnabled()) { + LOG.debug("Ignoring property " + method.getName()); } } diff --git a/plugins/osgi/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java b/plugins/osgi/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java index d501dbbfb..10f861d1e 100644 --- a/plugins/osgi/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java +++ b/plugins/osgi/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java @@ -228,8 +228,9 @@ public class FelixOsgiHost implements OsgiHost { //add all the bundles to the list for (File bundle : bundles) { String externalForm = bundle.toURI().toURL().toExternalForm(); - if (LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) { LOG.debug("Adding bundle [#0]", externalForm); + } bundleJars.add(externalForm); } diff --git a/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java b/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java index df9561cb9..f7162e5b8 100644 --- a/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java +++ b/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java @@ -107,8 +107,9 @@ public class OsgiConfigurationProvider implements PackageProvider, BundleListene */ protected void loadConfigFromBundle(Bundle bundle) { String bundleName = bundle.getSymbolicName(); - if (LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) { LOG.debug("Loading packages from bundle [#0]", bundleName); + } //init action context ActionContext ctx = ActionContext.getContext(); @@ -123,8 +124,9 @@ public class OsgiConfigurationProvider implements PackageProvider, BundleListene ctx.put(ClassLoaderInterface.CLASS_LOADER_INTERFACE, new BundleClassLoaderInterface()); ctx.put(BundleAccessor.CURRENT_BUNDLE_NAME, bundleName); - if (LOG.isTraceEnabled()) + if (LOG.isTraceEnabled()) { LOG.trace("Loading XML config from bundle [#0]", bundleName); + } //XML config PackageLoader loader = new BundlePackageLoader(); diff --git a/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/DefaultOValValidationManager.java b/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/DefaultOValValidationManager.java index 197a1d6b4..895826d7b 100644 --- a/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/DefaultOValValidationManager.java +++ b/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/DefaultOValValidationManager.java @@ -55,8 +55,9 @@ public class DefaultOValValidationManager implements OValValidationManager { configurers.add(annotationsConfigurer); if (validateJPAAnnotations) { - if (LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) { LOG.debug("Adding support for JPA annotations validations in OVal"); + } configurers.add(new JPAAnnotationsConfigurer()); } } @@ -139,8 +140,9 @@ public class DefaultOValValidationManager implements OValValidationManager { is = FileManager.loadFile(fileName, clazz); if (is != null) { - if (LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) { LOG.debug("Loading validation xml file [#0]", fileName); + } XMLConfigurer configurer = new XMLConfigurer(); configurer.fromXML(is); validatorFileCache.put(fileName, configurer); @@ -161,4 +163,4 @@ public class DefaultOValValidationManager implements OValValidationManager { return null; } -} \ No newline at end of file +} diff --git a/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/OValValidationInterceptor.java b/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/OValValidationInterceptor.java index ee42f1c6d..4b710d5ec 100644 --- a/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/OValValidationInterceptor.java +++ b/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/OValValidationInterceptor.java @@ -128,7 +128,9 @@ public class OValValidationInterceptor extends MethodFilterInterceptor { } catch (Exception e) { // If any exception occurred while doing reflection, we want // validate() to be executed - LOG.warn("An exception occured while executing the prefix method", e); + if (LOG.isWarnEnabled()) { + LOG.warn("An exception occured while executing the prefix method", e); + } exception = e; } @@ -157,8 +159,9 @@ public class OValValidationInterceptor extends MethodFilterInterceptor { String[] profileNames = profiles.value(); if (profileNames != null && profileNames.length > 0) { validator.disableAllProfiles(); - if (LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) { LOG.debug("Enabling profiles [#0]", StringUtils.join(profileNames, ",")); + } for (String profileName : profileNames) validator.enableProfile(profileName); } @@ -187,7 +190,9 @@ public class OValValidationInterceptor extends MethodFilterInterceptor { } if (isActionError(violation)) { + if (LOG.isDebugEnabled()) { LOG.debug("Adding action error '#0'", message); + } validatorContext.addActionError(message); } else { ValidationError validationError = buildValidationError(violation, message); @@ -198,7 +203,9 @@ public class OValValidationInterceptor extends MethodFilterInterceptor { fieldName = parentFieldname + "." + fieldName; } - LOG.debug("Adding field error [#0] with message '#1'", fieldName, validationError.getMessage()); + if (LOG.isDebugEnabled()) { + LOG.debug("Adding field error [#0] with message '#1'", fieldName, validationError.getMessage()); + } validatorContext.addFieldError(fieldName, validationError.getMessage()); // don't add "model." prefix to fields of model in model driven action diff --git a/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java b/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java index fdde2c098..3241aa877 100644 --- a/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java +++ b/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java @@ -158,7 +158,9 @@ public class PellMultiPartRequest implements MultiPartRequest { http.utils.multipartrequest.MultipartRequest.setEncoding("UTF-8"); } } catch (IllegalArgumentException e) { - LOG.info("Could not get encoding property 'struts.i18n.encoding' for file upload. Using system default"); + if (LOG.isInfoEnabled()) { + LOG.info("Could not get encoding property 'struts.i18n.encoding' for file upload. Using system default"); + } } catch (UnsupportedEncodingException e) { LOG.error("Encoding " + encoding + " is not a valid encoding. Please check your struts.properties file."); } diff --git a/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusFilter.java b/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusFilter.java index c1807efcc..4d0fb1326 100644 --- a/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusFilter.java +++ b/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusFilter.java @@ -82,7 +82,9 @@ public class PlexusFilter implements Filter { } if (parent.hasChildContainer(CHILD_CONTAINER_NAME)) { - LOG.warn("Plexus container (scope: request) alredy exist."); + if (LOG.isWarnEnabled()) { + LOG.warn("Plexus container (scope: request) alredy exist."); + } child = parent.getChildContainer(CHILD_CONTAINER_NAME); } else { child = parent.createChildContainer(CHILD_CONTAINER_NAME, Collections.EMPTY_LIST, Collections.EMPTY_MAP); diff --git a/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusObjectFactory.java b/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusObjectFactory.java index e4625246e..d85616881 100644 --- a/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusObjectFactory.java +++ b/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusObjectFactory.java @@ -294,7 +294,9 @@ public class PlexusObjectFactory extends ObjectFactory { return pc.lookup(role, roleHint); } catch (Exception e) { - LOG.debug("Can't load component (" + role + "/" + roleHint + ") with plexus, try now with struts.", e); + if (LOG.isDebugEnabled()) { + LOG.debug("Can't load component (" + role + "/" + roleHint + ") with plexus, try now with struts.", e); + } Object o = super.buildBean(super.getClassInstance(role), extraContext); pc.autowire(o); return o; diff --git a/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusUtils.java b/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusUtils.java index a01bcd4dd..c12f0ae5c 100644 --- a/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusUtils.java +++ b/plugins/plexus/src/main/java/org/apache/struts2/plexus/PlexusUtils.java @@ -47,7 +47,9 @@ public class PlexusUtils { public static void configure(PlexusContainer pc, String file) throws PlexusConfigurationResourceException { InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(file); if (is == null) { - LOG.info("Could not find " + file + ", skipping"); + if (LOG.isInfoEnabled()) { + LOG.info("Could not find " + file + ", skipping"); + } is = new ByteArrayInputStream("".getBytes()); } pc.setConfigurationResource(new InputStreamReader(is)); diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/context/PreparatorServlet.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/context/PreparatorServlet.java index 718cd3e1f..a181ef6a3 100644 --- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/context/PreparatorServlet.java +++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/context/PreparatorServlet.java @@ -44,7 +44,9 @@ public class PreparatorServlet extends HttpServlet implements StrutsStatics { @Override public void init(ServletConfig config) throws ServletException { + if (LOG.isWarnEnabled()) { LOG.warn("The preparator servlet has been deprecated. It can safely be removed from your web.xml file"); + } } } diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/context/ServletContextHolderListener.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/context/ServletContextHolderListener.java index 809eb1c25..4ab427518 100644 --- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/context/ServletContextHolderListener.java +++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/context/ServletContextHolderListener.java @@ -53,7 +53,9 @@ public class ServletContextHolderListener implements ServletContextListener { * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent event) { - LOG.warn("The ServletContextHolderListener has been deprecated. It can safely be removed from your web.xml file"); + if (LOG.isWarnEnabled()) { + LOG.warn("The ServletContextHolderListener has been deprecated. It can safely be removed from your web.xml file"); + } context = event.getServletContext(); } diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java index 14fdd7f26..1a1ba4a78 100644 --- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java +++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java @@ -442,8 +442,9 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics, sessionMap, applicationMap, request, response, servletRequest, servletResponse, servletContext, getPortletConfig(), phase); extraContext.put(PortletActionConstants.ACTION_MAPPING, mapping); - LOG.debug("Creating action proxy for name = " + actionName - + ", namespace = " + namespace); + if (LOG.isDebugEnabled()) { + LOG.debug("Creating action proxy for name = " + actionName + ", namespace = " + namespace); + } ActionProxy proxy = factory.createActionProxy(namespace, actionName, mapping.getMethod(), extraContext); request.setAttribute("struts.valueStack", proxy.getInvocation() @@ -609,7 +610,9 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics, public void destroy() { if (dispatcherUtils == null) { - LOG.warn("something is seriously wrong, DispatcherUtil is not initialized (null) "); + if (LOG.isWarnEnabled()) { + LOG.warn("something is seriously wrong, DispatcherUtil is not initialized (null) "); + } } else { dispatcherUtils.cleanup(); } diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptor.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptor.java index 32d8e7e3c..b9075c08c 100644 --- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptor.java +++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptor.java @@ -79,7 +79,9 @@ public class PortletAwareInterceptor extends AbstractInterceptor implements Port // Check if running in a servlet environment if (request == null) { - LOG.warn("This portlet preferences implementation should only be used during development"); + if (LOG.isWarnEnabled()) { + LOG.warn("This portlet preferences implementation should only be used during development"); + } ((PortletPreferencesAware)action).setPortletPreferences(new ServletPortletPreferences(ActionContext.getContext().getSession())); } else { ((PortletPreferencesAware)action).setPortletPreferences(request.getPreferences()); diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java index e217af035..2c807787d 100644 --- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java +++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java @@ -78,8 +78,10 @@ public class PortletUrlHelper { StringBuffer resultingAction = new StringBuffer(); RenderRequest request = PortletActionContext.getRenderRequest(); RenderResponse response = PortletActionContext.getRenderResponse(); - LOG.debug("Creating url. Action = " + action + ", Namespace = " + if (LOG.isDebugEnabled()) { + LOG.debug("Creating url. Action = " + action + ", Namespace = " + namespace + ", Type = " + type); + } namespace = prependNamespace(namespace, portletMode); if (StringUtils.isEmpty(portletMode)) { portletMode = PortletActionContext.getRenderRequest().getPortletMode().toString(); diff --git a/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java b/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java index a38023e16..90c73aac4 100644 --- a/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java +++ b/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionInvocation.java @@ -358,11 +358,10 @@ public class RestActionInvocation extends DefaultActionInvocation { ResultConfig resultConfig = this.proxy.getConfig().getResults() .get(defaultErrorResultName); if (resultConfig != null) { - this.result = objectFactory.buildResult(resultConfig, - invocationContext.getContextMap()); - if (LOG.isDebugEnabled()) { - LOG.debug("Found default error result."); - } + this.result = objectFactory.buildResult(resultConfig, invocationContext.getContextMap()); + if (LOG.isDebugEnabled()) { + LOG.debug("Found default error result."); + } } } @@ -446,7 +445,9 @@ public class RestActionInvocation extends DefaultActionInvocation { message += "] took " + total + " ms (execution: " + executionTime + " ms, result: " + processResult + " ms)"; - LOG.info(message); + if (LOG.isInfoEnabled()) { + LOG.info(message); + } } } diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/SiteGraph.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/SiteGraph.java index 881b6c9b1..2e2474ba8 100644 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/SiteGraph.java +++ b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/SiteGraph.java @@ -66,7 +66,9 @@ public class SiteGraph { } public static void main(String[] args) throws IOException { - LOG.info("SiteGraph starting..."); + if (LOG.isInfoEnabled()) { + LOG.info("SiteGraph starting..."); + } if (args.length != 8 && args.length != 6) { InputStream is = SiteGraph.class.getResourceAsStream("sitegraph-usage.txt"); diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java index 0ed8a7131..ebeee2d34 100644 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java +++ b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java @@ -104,7 +104,9 @@ public abstract class FileBasedView implements View { return buffer.toString(); } catch (FileNotFoundException e) { - LOG.warn("File not found"); + if (LOG.isWarnEnabled()) { + LOG.warn("File not found"); + } } catch (IOException e) { LOG.error("Cannot read file: "+file, e); } diff --git a/plugins/spring/src/main/java/org/apache/struts2/spring/ClassReloadingXMLWebApplicationContext.java b/plugins/spring/src/main/java/org/apache/struts2/spring/ClassReloadingXMLWebApplicationContext.java index 41ee04ac3..a22aac771 100644 --- a/plugins/spring/src/main/java/org/apache/struts2/spring/ClassReloadingXMLWebApplicationContext.java +++ b/plugins/spring/src/main/java/org/apache/struts2/spring/ClassReloadingXMLWebApplicationContext.java @@ -109,7 +109,9 @@ public class ClassReloadingXMLWebApplicationContext extends XmlWebApplicationCon classLoader.addResourceStore(new JarResourceStore(file)); //register with the fam fam.addListener(file, this); - LOG.debug("Watching [#0] for changes", file.getAbsolutePath()); + if (LOG.isDebugEnabled()) { + LOG.debug("Watching [#0] for changes", file.getAbsolutePath()); + } } else { //get all subdirs List dirs = new ArrayList(); @@ -120,7 +122,9 @@ public class ClassReloadingXMLWebApplicationContext extends XmlWebApplicationCon for (File dir : dirs) { //register with the fam fam.addListener(dir, this); - LOG.debug("Watching [#0] for changes", dir.getAbsolutePath()); + if (LOG.isDebugEnabled()) { + LOG.debug("Watching [#0] for changes", dir.getAbsolutePath()); + } } } } diff --git a/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java b/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java index 5767303d5..651233b93 100644 --- a/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java +++ b/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java @@ -73,7 +73,9 @@ public class StrutsSpringObjectFactory extends SpringObjectFactory { super(); boolean useClassCache = "true".equals(useClassCacheStr); - LOG.info("Initializing Struts-Spring integration..."); + if (LOG.isInfoEnabled()) { + LOG.info("Initializing Struts-Spring integration..."); + } Object rootWebApplicationContext = servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); @@ -109,7 +111,9 @@ public class StrutsSpringObjectFactory extends SpringObjectFactory { ClassReloadingXMLWebApplicationContext reloadingContext = (ClassReloadingXMLWebApplicationContext) appContext; reloadingContext.setupReloading(watchList.split(","), acceptClasses, servletContext, "true".equals(reloadConfig)); - LOG.info("Class reloading is enabled. Make sure this is not used on a production environment!", watchList); + if (LOG.isInfoEnabled()) { + LOG.info("Class reloading is enabled. Make sure this is not used on a production environment!", watchList); + } setClassLoader(reloadingContext.getReloadingClassLoader()); @@ -137,6 +141,8 @@ public class StrutsSpringObjectFactory extends SpringObjectFactory { this.setAlwaysRespectAutowireStrategy("true".equalsIgnoreCase(alwaysAutoWire)); - LOG.info("... initialized Struts-Spring integration successfully"); + if (LOG.isInfoEnabled()) { + LOG.info("... initialized Struts-Spring integration successfully"); + } } } diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesListener.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesListener.java index 5311334ec..b2213ca7e 100644 --- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesListener.java +++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesListener.java @@ -63,7 +63,9 @@ public class StrutsTilesListener extends TilesListener { context = decorate(context); } else { - LOG.warn("Tiles container factory is explicitly set. Not injecting struts configuration."); + if (LOG.isWarnEnabled()) { + LOG.warn("Tiles container factory is explicitly set. Not injecting struts configuration."); + } } return super.createContainer(context); } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ActionSupport.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ActionSupport.java index 70a38f33a..58d4d3065 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ActionSupport.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ActionSupport.java @@ -87,7 +87,9 @@ public class ActionSupport implements Action, Validateable, ValidationAware, Tex if (ctx != null) { return ctx.getLocale(); } else { - LOG.debug("Action context not initialized"); + if (LOG.isDebugEnabled()) { + LOG.debug("Action context not initialized"); + } return null; } } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java index 2a7f7489f..2cf4f0b31 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java @@ -199,7 +199,9 @@ public class ConfigurationManager { containerProvider.destroy(); } catch(Exception e) { - LOG.warn("error while destroying container provider ["+containerProvider+"]", e); + if (LOG.isWarnEnabled()) { + LOG.warn("error while destroying container provider ["+containerProvider+"]", e); + } } } containerProviders.clear(); @@ -261,7 +263,9 @@ public class ConfigurationManager { containerProvider.destroy(); } catch(Exception e) { + if (LOG.isWarnEnabled()) { LOG.warn("error while destroying configuration provider ["+containerProvider+"]", e); + } } } packageProviders = configuration.reloadContainer(providers); diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java index f77da0aa6..627e4411c 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java @@ -467,7 +467,7 @@ public class DefaultConfiguration implements Configuration { @Override public Object setProperty(String key, String value) { String oldValue = getProperty(key); - if (oldValue != null && !oldValue.equals(value) && !defaultFrameworkBeanName.equals(oldValue)) { + if (LOG.isInfoEnabled() && oldValue != null && !oldValue.equals(value) && !defaultFrameworkBeanName.equals(oldValue)) { LOG.info("Overriding property "+key+" - old value: "+oldValue+" new value: "+value); } return super.setProperty(key, value); diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/InterceptorBuilder.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/InterceptorBuilder.java index 102f08ef7..3decc6453 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/InterceptorBuilder.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/InterceptorBuilder.java @@ -70,9 +70,11 @@ public class InterceptorBuilder { inter = objectFactory.buildInterceptor(config, refParams); result.add(new InterceptorMapping(refName, inter)); } catch (ConfigurationException ex) { - LOG.warn("Unable to load config class " + config.getClassName() + " at " + + if (LOG.isWarnEnabled()) { + LOG.warn("Unable to load config class " + config.getClassName() + " at " + ex.getLocation() + " probably due to a missing jar, which might " + "be fine if you never plan to use the " + config.getName() + " interceptor"); + } LOG.error("Actual exception", ex); } @@ -147,7 +149,9 @@ public class InterceptorBuilder { params.put(name, map); } catch (Exception e) { - LOG.warn("No interceptor found for name = " + key); + if (LOG.isWarnEnabled()) { + LOG.warn("No interceptor found for name = " + key); + } } } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java index a35faebf8..350e87031 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java @@ -160,7 +160,9 @@ public class XmlConfigurationProvider implements ConfigurationProvider { } public void register(ContainerBuilder containerBuilder, LocatableProperties props) throws ConfigurationException { - LOG.info("Parsing configuration file [" + configFileName + "]"); + if (LOG.isInfoEnabled()) { + LOG.info("Parsing configuration file [" + configFileName + "]"); + } Map loadedBeans = new HashMap(); for (Document doc : documents) { Element rootElement = doc.getDocumentElement(); @@ -346,7 +348,9 @@ public class XmlConfigurationProvider implements ConfigurationProvider { Location location = DomHelper.getLocationObject(actionElement); if (location == null) { - LOG.warn("location null for " + className); + if (LOG.isWarnEnabled()) { + LOG.warn("location null for " + className); + } } //methodName should be null if it's not set methodName = (methodName.trim().length() > 0) ? methodName.trim() : null; @@ -425,7 +429,9 @@ public class XmlConfigurationProvider implements ConfigurationProvider { throw new ConfigurationException("Action class [" + className + "] does not have a public no-arg constructor", e, loc); } catch (RuntimeException ex) { // Probably not a big deal, like request or session-scoped Spring 2 beans that need a real request - LOG.info("Unable to verify action class [" + className + "] exists at initialization"); + if (LOG.isInfoEnabled()) { + LOG.info("Unable to verify action class [" + className + "] exists at initialization"); + } if (LOG.isDebugEnabled()) { LOG.debug("Action verification cause", ex); } @@ -529,11 +535,15 @@ public class XmlConfigurationProvider implements ConfigurationProvider { try { return objectFactory.getClassInstance(className); } catch (ClassNotFoundException e) { - LOG.warn("Result class [" + className + "] doesn't exist (ClassNotFoundException) at " + + if (LOG.isWarnEnabled()) { + LOG.warn("Result class [" + className + "] doesn't exist (ClassNotFoundException) at " + loc.toString() + ", ignoring", e); + } } catch (NoClassDefFoundError e) { - LOG.warn("Result class [" + className + "] doesn't exist (NoClassDefFoundError) at " + + if (LOG.isWarnEnabled()) { + LOG.warn("Result class [" + className + "] doesn't exist (NoClassDefFoundError) at " + loc.toString() + ", ignoring", e); + } } return null; @@ -665,7 +675,9 @@ public class XmlConfigurationProvider implements ConfigurationProvider { resultParams.put(paramName, val); } } else { - LOG.warn("no default parameter defined for result of type " + config.getName()); + if (LOG.isWarnEnabled()) { + LOG.warn("no default parameter defined for result of type " + config.getName()); + } } } } @@ -885,8 +897,10 @@ public class XmlConfigurationProvider implements ConfigurationProvider { if (errorIfMissing) { throw new ConfigurationException("Could not open files of the name " + fileName, ioException); } else { - LOG.info("Unable to locate configuration files of the name " + if (LOG.isInfoEnabled()) { + LOG.info("Unable to locate configuration files of the name " + fileName + ", skipping"); + } return docs; } } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultObjectTypeDeterminer.java b/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultObjectTypeDeterminer.java index d4b7e0010..106787bb1 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultObjectTypeDeterminer.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultObjectTypeDeterminer.java @@ -131,7 +131,7 @@ public class DefaultObjectTypeDeterminer implements ObjectTypeDeterminer { clazz = (Class) xworkConverter .getConverter(parentClass, DEPRECATED_ELEMENT_PREFIX + property); - if (clazz != null) { + if (LOG.isInfoEnabled() && clazz != null) { LOG.info("The Collection_xxx pattern for collection type conversion is deprecated. Please use Element_xxx!"); } } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java index 4132c3a13..b29437544 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java @@ -183,7 +183,9 @@ public class AliasInterceptor extends AbstractInterceptor { if (clearableStack && (stack.getContext() != null) && (newStack.getContext() != null)) stack.getContext().put(ActionContext.CONVERSION_ERRORS, newStack.getContext().get(ActionContext.CONVERSION_ERRORS)); } else { - LOG.debug("invalid alias expression:" + aliasesKey); + if (LOG.isDebugEnabled()) { + LOG.debug("invalid alias expression:" + aliasesKey); + } } } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/LoggingInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/LoggingInterceptor.java index d71956990..a5aa1b280 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/LoggingInterceptor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/LoggingInterceptor.java @@ -79,7 +79,9 @@ public class LoggingInterceptor extends AbstractInterceptor { } message.append(invocation.getProxy().getActionName()); - LOG.info(message.toString()); + if (LOG.isInfoEnabled()) { + LOG.info(message.toString()); + } } } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java index 1ccf7cf0a..539410f8c 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java @@ -244,7 +244,9 @@ public class OgnlUtil { */ public void copy(Object from, Object to, Map context, Collection exclusions, Collection inclusions) { if (from == null || to == null) { - LOG.warn("Attempting to copy from or to a null source. This is illegal and is bein skipped. This may be due to an error in an OGNL expression, action chaining, or some other event."); + if (LOG.isWarnEnabled()) { + LOG.warn("Attempting to copy from or to a null source. This is illegal and is bein skipped. This may be due to an error in an OGNL expression, action chaining, or some other event."); + } return; } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkCollectionPropertyAccessor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkCollectionPropertyAccessor.java index 32cf2edca..e7fe8c502 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkCollectionPropertyAccessor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkCollectionPropertyAccessor.java @@ -81,7 +81,9 @@ public class XWorkCollectionPropertyAccessor extends SetPropertyAccessor { public Object getProperty(Map context, Object target, Object key) throws OgnlException { - LOG.debug("Entering getProperty()"); + if (LOG.isDebugEnabled()) { + LOG.debug("Entering getProperty()"); + } //check if it is a generic type property. //if so, return the value from the @@ -185,13 +187,19 @@ public class XWorkCollectionPropertyAccessor extends SetPropertyAccessor { */ private Map getSetMap(Map context, Collection collection, String property, Class valueClass) throws OgnlException { - LOG.debug("getting set Map"); + if (LOG.isDebugEnabled()) { + LOG.debug("getting set Map"); + } + String path = ReflectionContextState.getCurrentPropertyPath(context); Map map = ReflectionContextState.getSetMap(context, path); if (map == null) { - LOG.debug("creating set Map"); + if (LOG.isDebugEnabled()) { + LOG.debug("creating set Map"); + } + map = new HashMap(); map.put(null, new SurrugateList(collection)); for (Object currTest : collection) { diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java b/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java index ea9b79760..21a761023 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java @@ -74,23 +74,33 @@ public class SpringObjectFactory extends ObjectFactory implements ApplicationCon public void setAutowireStrategy(int autowireStrategy) { switch (autowireStrategy) { case AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT: - LOG.info("Setting autowire strategy to autodetect"); + if (LOG.isInfoEnabled()) { + LOG.info("Setting autowire strategy to autodetect"); + } this.autowireStrategy = autowireStrategy; break; case AutowireCapableBeanFactory.AUTOWIRE_BY_NAME: - LOG.info("Setting autowire strategy to name"); + if (LOG.isInfoEnabled()) { + LOG.info("Setting autowire strategy to name"); + } this.autowireStrategy = autowireStrategy; break; case AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE: - LOG.info("Setting autowire strategy to type"); + if (LOG.isInfoEnabled()) { + LOG.info("Setting autowire strategy to type"); + } this.autowireStrategy = autowireStrategy; break; case AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR: - LOG.info("Setting autowire strategy to constructor"); + if (LOG.isInfoEnabled()) { + LOG.info("Setting autowire strategy to constructor"); + } this.autowireStrategy = autowireStrategy; break; case AutowireCapableBeanFactory.AUTOWIRE_NO: - LOG.info("Setting autowire strategy to none"); + if (LOG.isInfoEnabled()) { + LOG.info("Setting autowire strategy to none"); + } this.autowireStrategy = autowireStrategy; break; default: diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringProxyableObjectFactory.java b/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringProxyableObjectFactory.java index db3d89d35..8d5a5241f 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringProxyableObjectFactory.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringProxyableObjectFactory.java @@ -66,7 +66,9 @@ public class SpringProxyableObjectFactory extends SpringObjectFactory { try { return anAppContext.getBean(beanName); } catch (NoSuchBeanDefinitionException e2) { - LOG.warn("Could not register new bean definition for bean " + beanName); + if (LOG.isWarnEnabled()) { + LOG.warn("Could not register new bean definition for bean " + beanName); + } skipBeanNames.add(beanName); } } catch (ClassNotFoundException e1) { diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptor.java index c76ccc254..473e0dc49 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptor.java @@ -97,7 +97,9 @@ public class ActionAutowiringInterceptor extends AbstractInterceptor implements WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (applicationContext == null) { - LOG.warn("ApplicationContext could not be found. Action classes will not be autowired."); + if (LOG.isWarnEnabled()) { + LOG.warn("ApplicationContext could not be found. Action classes will not be autowired."); + } } else { setApplicationContext(applicationContext); factory = new SpringObjectFactory(); diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/FileManager.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/FileManager.java index 757e42c66..b092972bc 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/FileManager.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/FileManager.java @@ -294,7 +294,9 @@ public class FileManager { separatorIndex = fileName.lastIndexOf(JAR_FILE_EXTENSION_END); } if (separatorIndex == -1) { - LOG.warn("Could not find end of jar file!"); + if (LOG.isWarnEnabled()) { + LOG.warn("Could not find end of jar file!"); + } return null; } // Split file name @@ -311,7 +313,9 @@ public class FileManager { return null; } } catch (Throwable e) { - LOG.warn("Could not create JarEntryRevision for [" + jarFileName + "]!", e); + if (LOG.isWarnEnabled()) { + LOG.warn("Could not create JarEntryRevision for [" + jarFileName + "]!", e); + } return null; } } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java index 6f2eecf2d..daa6299e3 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java @@ -407,7 +407,9 @@ public class LocalizedTextUtil { ValueStack valueStack) { String indexedTextName = null; if (aTextName == null) { - LOG.warn("Trying to find text with null key!"); + if (LOG.isWarnEnabled()) { + LOG.warn("Trying to find text with null key!"); + } aTextName = ""; } // calculate indexedTextName (collection[*]) if applicable @@ -537,7 +539,7 @@ public class LocalizedTextUtil { } // could we find the text, if not log a warn - if (unableToFindTextForKey(result)) { + if (unableToFindTextForKey(result) && LOG.isDebugEnabled()) { String warn = "Unable to find text for key '" + aTextName + "' "; if (indexedTextName != null) { warn += " or indexed key '" + indexedTextName + "' "; @@ -632,7 +634,7 @@ public class LocalizedTextUtil { } GetDefaultMessageReturnArg result = getDefaultMessage(aTextName, locale, valueStack, args, defaultMessage); - if (unableToFindTextForKey(result)) { + if (LOG.isWarnEnabled() && unableToFindTextForKey(result)) { LOG.warn("Unable to find text for key '" + aTextName + "' in ResourceBundles for locale '" + locale + "'"); } return result != null ? result.message : null; @@ -803,7 +805,9 @@ public class LocalizedTextUtil { } } } catch (Exception e) { - LOG.warn("couldn't clear tomcat cache", e); + if (LOG.isWarnEnabled()) { + LOG.warn("couldn't clear tomcat cache", e); + } } } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/ResolverUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/ResolverUtil.java index 0e583f92e..59d1f3ccf 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/ResolverUtil.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/ResolverUtil.java @@ -322,7 +322,9 @@ public class ResolverUtil { urls = loader.getResources(packageName); } catch (IOException ioe) { - LOG.warn("Could not read package: " + packageName, ioe); + if (LOG.isWarnEnabled()) { + LOG.warn("Could not read package: " + packageName, ioe); + } return; } @@ -341,7 +343,9 @@ public class ResolverUtil { urlPath = urlPath.substring(0, urlPath.indexOf('!')); } - LOG.info("Scanning for classes in [" + urlPath + "] matching criteria: " + test); + if (LOG.isInfoEnabled()) { + LOG.info("Scanning for classes in [" + urlPath + "] matching criteria: " + test); + } File file = new File(urlPath); if ( file.isDirectory() ) { loadImplementationsInDirectory(test, packageName, file); @@ -351,7 +355,9 @@ public class ResolverUtil { } } catch (IOException ioe) { - LOG.warn("could not read entries", ioe); + if (LOG.isWarnEnabled()) { + LOG.warn("could not read entries", ioe); + } } } } @@ -451,8 +457,10 @@ public class ResolverUtil { } } catch (Throwable t) { - LOG.warn("Could not examine class '" + fqn + "' due to a " + + if (LOG.isWarnEnabled()) { + LOG.warn("Could not examine class '" + fqn + "' due to a " + t.getClass().getName() + " with message: " + t.getMessage()); + } } } } \ No newline at end of file diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/profiling/UtilTimerStack.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/profiling/UtilTimerStack.java index 2322f939c..13727e568 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/profiling/UtilTimerStack.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/profiling/UtilTimerStack.java @@ -355,7 +355,9 @@ public class UtilTimerStack { printTimes(currentTimer); current.set(null); //prevent printing multiple times - LOG.warn("Unmatched Timer. Was expecting " + currentTimer.getResource() + ", instead got " + name); + if (LOG.isWarnEnabled()) { + LOG.warn("Unmatched Timer. Was expecting " + currentTimer.getResource() + ", instead got " + name); + } } } @@ -369,7 +371,9 @@ public class UtilTimerStack */ private static void printTimes(ProfilingTimerBean currentTimer) { - LOG.info(currentTimer.getPrintable(getMinTime())); + if (LOG.isInfoEnabled()) { + LOG.info(currentTimer.getPrintable(getMinTime())); + } } /** diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFileParser.java b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFileParser.java index 38be46802..0ca98cf13 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFileParser.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFileParser.java @@ -231,7 +231,9 @@ public class DefaultValidatorFileParser implements ValidatorFileParser { if (messageParams != null && (messageParams.size() > 0)) { // we are i18n message parameters defined but no i18n message, // let's warn the user. - LOG.warn("validator of type ["+validatorType+"] have i18n message parameters defined but no i18n message key, it's parameters will be ignored"); + if (LOG.isWarnEnabled()) { + LOG.warn("validator of type ["+validatorType+"] have i18n message parameters defined but no i18n message key, it's parameters will be ignored"); + } } } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java index 7bf027721..b5c8973bc 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java @@ -240,7 +240,9 @@ public class ValidationInterceptor extends MethodFilterInterceptor { catch(Exception e) { // If any exception occurred while doing reflection, we want // validate() to be executed - LOG.warn("an exception occured while executing the prefix method", e); + if (LOG.isWarnEnabled()) { + LOG.warn("an exception occured while executing the prefix method", e); + } exception = e; } diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RepopulateConversionErrorFieldValidatorSupport.java b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RepopulateConversionErrorFieldValidatorSupport.java index 15c284b91..d794610ef 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RepopulateConversionErrorFieldValidatorSupport.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RepopulateConversionErrorFieldValidatorSupport.java @@ -174,7 +174,9 @@ public abstract class RepopulateConversionErrorFieldValidatorSupport extends Fie doExprOverride = true; fakeParams.put(fullFieldName, "'" + tmpValue[0] + "'"); } else { - LOG.warn("value is an empty array of String or with first element in it as null [" + value + "], will not repopulate conversion error "); + if (LOG.isWarnEnabled()) { + LOG.warn("value is an empty array of String or with first element in it as null [" + value + "], will not repopulate conversion error "); + } } } else if (value instanceof String) { String tmpValue = (String) value; @@ -182,7 +184,9 @@ public abstract class RepopulateConversionErrorFieldValidatorSupport extends Fie fakeParams.put(fullFieldName, "'" + tmpValue + "'"); } else { // opps... it should be - LOG.warn("conversion error value is not a String or array of String but instead is [" + value + "], will not repopulate conversion error"); + if (LOG.isWarnEnabled()) { + LOG.warn("conversion error value is not a String or array of String but instead is [" + value + "], will not repopulate conversion error"); + } } if (doExprOverride) {