http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkConverter.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkConverter.java b/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkConverter.java index 9599b95..eaae007 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkConverter.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkConverter.java @@ -313,8 +313,7 @@ public class XWorkConverter extends DefaultTypeConverter { try { return tc.convertValue(context, target, member, property, value, toClass); } catch (Exception e) { - if (LOG.isDebugEnabled()) - LOG.debug("unable to convert value using type converter [#0]", e, tc.getClass().getName()); + LOG.debug("Unable to convert value using type converter [{}]", tc.getClass().getName(), e); handleConversionException(context, property, value, target); return TypeConverter.NO_CONVERSION_POSSIBLE; @@ -323,24 +322,20 @@ public class XWorkConverter extends DefaultTypeConverter { if (defaultTypeConverter != null) { try { - if (LOG.isDebugEnabled()) - LOG.debug("falling back to default type converter [" + defaultTypeConverter + "]"); + LOG.debug("Falling back to default type converter [{}]", defaultTypeConverter); return defaultTypeConverter.convertValue(context, target, member, property, value, toClass); } catch (Exception e) { - if (LOG.isDebugEnabled()) - LOG.debug("unable to convert value using type converter [#0]", e, defaultTypeConverter.getClass().getName()); + LOG.debug("Unable to convert value using type converter [{}]", defaultTypeConverter.getClass().getName(), e); handleConversionException(context, property, value, target); return TypeConverter.NO_CONVERSION_POSSIBLE; } } else { try { - if (LOG.isDebugEnabled()) - LOG.debug("falling back to Ognl's default type conversion"); + LOG.debug("Falling back to Ognl's default type conversion"); return super.convertValue(value, toClass); } catch (Exception e) { - if (LOG.isDebugEnabled()) - LOG.debug("unable to convert value using type converter [#0]", e, super.getClass().getName()); + LOG.debug("Unable to convert value using type converter [{}]", super.getClass().getName(), e); handleConversionException(context, property, value, target); return TypeConverter.NO_CONVERSION_POSSIBLE; @@ -368,9 +363,7 @@ public class XWorkConverter extends DefaultTypeConverter { try { clazz = Thread.currentThread().getContextClassLoader().loadClass(className); } catch (ClassNotFoundException cnfe) { - if (LOG.isDebugEnabled()) { - LOG.debug("Cannot load class #0", cnfe, className); - } + LOG.debug("Cannot load class {}", className, cnfe); } result = lookupSuper(clazz); @@ -408,9 +401,8 @@ public class XWorkConverter extends DefaultTypeConverter { } protected Object getConverter(Class clazz, String property) { - if (LOG.isDebugEnabled()) { - LOG.debug("Retrieving convert for class [#0] and property [#1]", clazz, property); - } + LOG.debug("Retrieving convert for class [{}] and property [{}]", clazz, property); + synchronized (clazz) { if ((property != null) && !converterHolder.containsNoMapping(clazz)) { try { @@ -423,17 +415,15 @@ public class XWorkConverter extends DefaultTypeConverter { } Object converter = mapping.get(property); - if (LOG.isDebugEnabled() && converter == null) { - LOG.debug("Converter is null for property [#0]. Mapping size [#1]:", property, mapping.size()); + if (converter == null && LOG.isDebugEnabled()) { + LOG.debug("Converter is null for property [{}]. Mapping size [{}]:", property, mapping.size()); for (String next : mapping.keySet()) { - LOG.debug(next + ":" + mapping.get(next)); + LOG.debug("{}:{}", next, mapping.get(next)); } } return converter; } catch (Throwable t) { - if (LOG.isDebugEnabled()) { - LOG.debug("Got exception trying to resolve convert for class [#0] and property [#1]", t, clazz, property); - } + LOG.debug("Got exception trying to resolve convert for class [{}] and property [{}]", clazz, property, t); converterHolder.addNoMapping(clazz); } } @@ -499,9 +489,9 @@ public class XWorkConverter extends DefaultTypeConverter { } if (LOG.isDebugEnabled()) { if (StringUtils.isEmpty(tc.key())) { - LOG.debug("WARNING! key of @TypeConversion [#0] applied to [#1] is empty!", tc.converter(), clazz.getName()); + LOG.debug("WARNING! key of @TypeConversion [{}] applied to [{}] is empty!", tc.converter(), clazz.getName()); } else { - LOG.debug("TypeConversion [#0] with key: [#1]", tc.converter(), tc.key()); + LOG.debug("TypeConversion [{}] with key: [{}]", tc.converter(), tc.key()); } } annotationProcessor.process(mapping, tc, tc.key()); @@ -522,9 +512,7 @@ public class XWorkConverter extends DefaultTypeConverter { // Default to the property name if (StringUtils.isEmpty(key)) { key = AnnotationUtils.resolvePropertyName(method); - if (LOG.isDebugEnabled()) { - LOG.debug("Retrieved key [#0] from method name [#1]", key, method.getName()); - } + LOG.debug("Retrieved key [{}] from method name [{}]", key, method.getName()); } annotationProcessor.process(mapping, tc, key); }
http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/factory/DefaultConverterFactory.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/factory/DefaultConverterFactory.java b/xwork-core/src/main/java/com/opensymphony/xwork2/factory/DefaultConverterFactory.java index 73596c8..e35222e 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/factory/DefaultConverterFactory.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/factory/DefaultConverterFactory.java @@ -23,9 +23,7 @@ public class DefaultConverterFactory implements ConverterFactory { } public TypeConverter buildConverter(Class<? extends TypeConverter> converterClass, Map<String, Object> extraContext) throws Exception { - if (LOG.isDebugEnabled()) { - LOG.debug("Creating converter of type [#0]", converterClass.getCanonicalName()); - } + LOG.debug("Creating converter of type [{}]", converterClass.getCanonicalName()); return container.getInstance(converterClass); } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java index 4d13f40..a2ac59c 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java @@ -151,9 +151,7 @@ public class DefaultWorkflowInterceptor extends MethodFilterInterceptor { ValidationAware validationAwareAction = (ValidationAware) action; if (validationAwareAction.hasErrors()) { - if (LOG.isDebugEnabled()) { - LOG.debug("Errors on action [#0], returning result name [#1]", validationAwareAction, inputResultName); - } + LOG.debug("Errors on action [{}], returning result name [{}]", validationAwareAction, inputResultName); String resultName = inputResultName; resultName = processValidationWorkflowAware(action, resultName); @@ -174,10 +172,8 @@ public class DefaultWorkflowInterceptor extends MethodFilterInterceptor { String resultName = currentResultName; if (action instanceof ValidationWorkflowAware) { resultName = ((ValidationWorkflowAware) action).getInputResultName(); - if (LOG.isDebugEnabled()) { - LOG.debug("Changing result name from [#0] to [#1] because of processing [#2] interface applied to [#3]", + LOG.debug("Changing result name from [{}] to [{}] because of processing [{}] interface applied to [{}]", currentResultName, resultName, InputConfig.class.getSimpleName(), ValidationWorkflowAware.class.getSimpleName(), action); - } } return resultName; } @@ -195,10 +191,8 @@ public class DefaultWorkflowInterceptor extends MethodFilterInterceptor { } else { resultName = annotation.resultName(); } - if (LOG.isDebugEnabled()) { - LOG.debug("Changing result name from [#0] to [#1] because of processing annotation [#2] on action [#3]", + LOG.debug("Changing result name from [{}] to [{}] because of processing annotation [{}] on action [{}]", currentResultName, resultName, InputConfig.class.getSimpleName(), action); - } } return resultName; } @@ -210,10 +204,8 @@ public class DefaultWorkflowInterceptor extends MethodFilterInterceptor { String resultName = currentResultName; if (action instanceof ValidationErrorAware) { resultName = ((ValidationErrorAware) action).actionErrorOccurred(currentResultName); - if (LOG.isDebugEnabled()) { - LOG.debug("Changing result name from [#0] to [#1] because of processing interface [#2] on action [#3]", + LOG.debug("Changing result name from [{}] to [{}] because of processing interface [{}] on action [{}]", currentResultName, resultName, ValidationErrorAware.class.getSimpleName(), action); - } } return resultName; } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java index 1d52c9c..99aadef 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java @@ -123,7 +123,7 @@ public class I18nInterceptor extends AbstractInterceptor { @Override public String intercept(ActionInvocation invocation) throws Exception { if (LOG.isDebugEnabled()) { - LOG.debug("intercept '#0/#1' {", + LOG.debug("Intercept '{}/{}' {", invocation.getProxy().getNamespace(), invocation.getProxy().getActionName()); } @@ -133,13 +133,13 @@ public class I18nInterceptor extends AbstractInterceptor { saveLocale(invocation, locale); if (LOG.isDebugEnabled()) { - LOG.debug("before Locale=#0", invocation.getStack().findValue("locale")); + LOG.debug("before Locale: {}", invocation.getStack().findValue("locale")); } final String result = invocation.invoke(); if (LOG.isDebugEnabled()) { - LOG.debug("after Locale=#0", invocation.getStack().findValue("locale")); + LOG.debug("after Locale {}", invocation.getStack().findValue("locale")); LOG.debug("intercept } "); } @@ -222,8 +222,8 @@ public class I18nInterceptor extends AbstractInterceptor { locale = (requestedLocale instanceof Locale) ? (Locale) requestedLocale : LocalizedTextUtil.localeFromString(requestedLocale.toString(), null); - if (locale != null && LOG.isDebugEnabled()) { - LOG.debug("applied request locale=#0", locale); + if (locale != null) { + LOG.debug("Applied request locale: {}", locale); } } return locale; @@ -252,9 +252,7 @@ public class I18nInterceptor extends AbstractInterceptor { Object sessionLocale = session.get(attributeName); if (sessionLocale != null && sessionLocale instanceof Locale) { Locale locale = (Locale) sessionLocale; - if (LOG.isDebugEnabled()) { - LOG.debug("applied session locale=#0", locale); - } + LOG.debug("Applied session locale: {}", locale); return locale; } return null; @@ -263,8 +261,8 @@ public class I18nInterceptor extends AbstractInterceptor { protected Locale readStoredLocalFromCurrentInvocation(ActionInvocation invocation) { // no overriding locale definition found, stay with current invocation (=browser) locale Locale locale = invocation.getInvocationContext().getLocale(); - if (locale != null && LOG.isDebugEnabled()) { - LOG.debug("applied invocation context locale=#0", locale); + if (locale != null) { + LOG.debug("Applied invocation context locale: {}", locale); } return locale; } @@ -275,9 +273,7 @@ public class I18nInterceptor extends AbstractInterceptor { && ((Object[]) requestedLocale).length > 0) { requestedLocale = ((Object[]) requestedLocale)[0]; - if (LOG.isDebugEnabled()) { - LOG.debug("requested_locale=#0", requestedLocale); - } + LOG.debug("Requested locale: {}", requestedLocale); } return requestedLocale; } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java index d2074ac..78d873d 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java @@ -412,7 +412,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor { protected boolean acceptableName(String name) { boolean accepted = isWithinLengthLimit(name) && !isExcluded(name) && isAccepted(name); if (devMode && accepted) { // notify only when in devMode - LOG.debug("Parameter [#0] was accepted and will be appended to action!", name); + LOG.debug("Parameter [{}] was accepted and will be appended to action!", name); } return accepted; } @@ -420,7 +420,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor { protected boolean isWithinLengthLimit( String name ) { boolean matchLength = name.length() <= paramNameMaxLength; if (!matchLength) { - notifyDeveloper("Parameter [#0] is too long, allowed length is [#1]", name, String.valueOf(paramNameMaxLength)); + notifyDeveloper("Parameter [{}] is too long, allowed length is [{}]", name, String.valueOf(paramNameMaxLength)); } return matchLength; } @@ -430,14 +430,14 @@ public class ParametersInterceptor extends MethodFilterInterceptor { if (result.isAccepted()) { return true; } - notifyDeveloper("Parameter [#0] didn't match accepted pattern [#1]!", paramName, result.getAcceptedPattern()); + notifyDeveloper("Parameter [{}] didn't match accepted pattern [{}]!", paramName, result.getAcceptedPattern()); return false; } protected boolean isExcluded(String paramName) { ExcludedPatternsChecker.IsExcluded result = excludedPatterns.isExcluded(paramName); if (result.isExcluded()) { - notifyDeveloper("Parameter [#0] matches excluded pattern [#1]!", paramName, result.getExcludedPattern()); + notifyDeveloper("Parameter [{}] matches excluded pattern [{}]!", paramName, result.getExcludedPattern()); return true; } return false; http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtil.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtil.java index aa1540b..28895a7 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtil.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtil.java @@ -146,9 +146,7 @@ public class PrefixMethodInvocationUtil { } catch (NoSuchMethodException e) { // hmm -- OK, try next prefix - if (LOG.isDebugEnabled()) { - LOG.debug("cannot find method [#0] in action [#1]", prefixedMethodName, action.toString()); - } + LOG.debug("Cannot find method [{}] in action [{}]", prefixedMethodName, action.toString()); } } return null; http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java index 0f1c048..f4cc3fe 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java @@ -199,9 +199,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS .build(); throw new XWorkException(message, re); } else { - if (LOG.isWarnEnabled()) { - LOG.warn("Error setting value [#0] with expression [#1]", re, value.toString(), expr); - } + LOG.warn("Error setting value [{}] with expression [{}]", value, expr, re); } } @@ -333,7 +331,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS Object ret = findInContext(expr); if (ret == null) { if (shouldLogMissingPropertyWarning(e)) { - LOG.warn("Could not find property [#0]!", e, expr); + LOG.warn("Could not find property [{}]!", expr, e); } if (throwExceptionOnFailure) { throw new XWorkException(e); @@ -381,12 +379,11 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS * @param e The thrown exception. */ private void logLookupFailure(String expr, Exception e) { - String msg = LoggerUtils.format("Caught an exception while evaluating expression '#0' against value stack", expr); if (devMode && LOG.isWarnEnabled()) { - LOG.warn(msg, e); + LOG.warn("Caught an exception while evaluating expression '{}' against value stack", expr, e); LOG.warn("NOTE: Previous warning message was issued due to devMode set to true."); - } else if (LOG.isDebugEnabled()) { - LOG.debug(msg, e); + } else { + LOG.debug("Caught an exception while evaluating expression '{}' against value stack", expr, e); } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java index 040077d..075237b 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java @@ -53,9 +53,7 @@ public class SecurityMemberAccess extends DefaultMemberAccess { @Override public boolean isAccessible(Map context, Object target, Member member, String propertyName) { if (checkEnumAccess(target, member)) { - if (LOG.isTraceEnabled()) { - LOG.trace("Allowing access to enum #0", target); - } + LOG.trace("Allowing access to enum {}", target); return true; } @@ -63,40 +61,30 @@ public class SecurityMemberAccess extends DefaultMemberAccess { Class memberClass = member.getDeclaringClass(); if (Modifier.isStatic(member.getModifiers()) && allowStaticMethodAccess) { - if (LOG.isDebugEnabled()) { - LOG.debug("Support for accessing static methods [target: #0, member: #1, property: #2] is deprecated!", target, member, propertyName); - } + LOG.debug("Support for accessing static methods [target: {}, member: {}, property: {}] is deprecated!", target, member, propertyName); if (!isClassExcluded(member.getDeclaringClass())) { targetClass = member.getDeclaringClass(); } } if (isPackageExcluded(targetClass.getPackage(), memberClass.getPackage())) { - if (LOG.isWarnEnabled()) { - LOG.warn("Package of target [#0] or package of member [#1] are excluded!", target, member); - } + LOG.warn("Package of target [{}] or package of member [{}] are excluded!", target, member); return false; } if (isClassExcluded(targetClass)) { - if (LOG.isWarnEnabled()) { - LOG.warn("Target class [#0] is excluded!", target); - } + LOG.warn("Target class [{}] is excluded!", target); return false; } if (isClassExcluded(memberClass)) { - if (LOG.isWarnEnabled()) { - LOG.warn("Declaring class of member type [#0] is excluded!", member); - } + LOG.warn("Declaring class of member type [{}] is excluded!", member); return false; } boolean allow = true; if (!checkStaticMethodAccess(member)) { - if (LOG.isTraceEnabled()) { - LOG.warn("Access to static [#0] is blocked!", member); - } + LOG.warn("Access to static [{}] is blocked!", member); allow = false; } @@ -128,7 +116,7 @@ public class SecurityMemberAccess extends DefaultMemberAccess { } protected boolean isPackageExcluded(Package targetPackage, Package memberPackage) { - if (LOG.isWarnEnabled() && (targetPackage == null || memberPackage == null)) { + if (targetPackage == null || memberPackage == null) { LOG.warn("The use of the default (unnamed) package is discouraged!"); } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java index bad1fc0..d02e84b 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java @@ -210,13 +210,9 @@ public class CompoundRootAccessor implements PropertyAccessor, MethodAccessor, C return sb.toString(); } catch (IntrospectionException e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Got exception in callMethod", e); - } + LOG.debug("Got exception in callMethod", e); } catch (OgnlException e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Got exception in callMethod", e); - } + LOG.debug("Got exception in callMethod", e); } return null; @@ -281,9 +277,7 @@ public class CompoundRootAccessor implements PropertyAccessor, MethodAccessor, C } } } catch (Exception e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Got exception when tried to get class for name [#0]", e, className); - } + LOG.debug("Got exception when tried to get class for name [{}]", className, e); } return Thread.currentThread().getContextClassLoader().loadClass(className); http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkMethodAccessor.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkMethodAccessor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkMethodAccessor.java index 7d38122..55b6280 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkMethodAccessor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkMethodAccessor.java @@ -120,8 +120,7 @@ public class XWorkMethodAccessor extends ObjectMethodAccessor { if (LOG.isDebugEnabled()) { if (!(e.getReason() instanceof NoSuchMethodException)) { // the method exists on the target object, but something went wrong - String s = "Error calling method through OGNL: object: [#0] method: [#1] args: [#2]"; - LOG.debug(s, e.getReason(), object.toString(), methodName, Arrays.toString(objects)); + LOG.debug( "Error calling method through OGNL: object: [{}] method: [{}] args: [{}]", e.getReason(), object.toString(), methodName, Arrays.toString(objects)); } } throw e; @@ -149,8 +148,7 @@ public class XWorkMethodAccessor extends ObjectMethodAccessor { if (LOG.isDebugEnabled()) { if (!(e.getReason() instanceof NoSuchMethodException)) { // the method exists on the target class, but something went wrong - String s = "Error calling method through OGNL, class: [#0] method: [#1] args: [#2]"; - LOG.debug(s, e.getReason(), aClass.getName(), methodName, Arrays.toString(objects)); + LOG.debug("Error calling method through OGNL, class: [{}] method: [{}] args: [{}]", e.getReason(), aClass.getName(), methodName, Arrays.toString(objects)); } } throw e; http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultAcceptedPatternsChecker.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultAcceptedPatternsChecker.java b/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultAcceptedPatternsChecker.java index 20eeff8..deb7c03 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultAcceptedPatternsChecker.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultAcceptedPatternsChecker.java @@ -27,10 +27,8 @@ public class DefaultAcceptedPatternsChecker implements AcceptedPatternsChecker { @Inject(value = XWorkConstants.OVERRIDE_ACCEPTED_PATTERNS, required = false) public void setOverrideAcceptedPatterns(String acceptablePatterns) { - if (LOG.isWarnEnabled()) { - LOG.warn("Overriding accepted patterns [#0] with [#1], be aware that this affects all instances and safety of your application!", + LOG.warn("Overriding accepted patterns [{}] with [{}], be aware that this affects all instances and safety of your application!", XWorkConstants.OVERRIDE_ACCEPTED_PATTERNS, acceptablePatterns); - } acceptedPatterns = new HashSet<Pattern>(); for (String pattern : TextParseUtil.commaDelimitedStringToSet(acceptablePatterns)) { acceptedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); @@ -39,9 +37,7 @@ public class DefaultAcceptedPatternsChecker implements AcceptedPatternsChecker { @Inject(value = XWorkConstants.ADDITIONAL_ACCEPTED_PATTERNS, required = false) public void setAdditionalAcceptedPatterns(String acceptablePatterns) { - if (LOG.isDebugEnabled()) { - LOG.warn("Adding additional global patterns [#0] to accepted patterns!", acceptablePatterns); - } + LOG.warn("Adding additional global patterns [{}] to accepted patterns!", acceptablePatterns); for (String pattern : TextParseUtil.commaDelimitedStringToSet(acceptablePatterns)) { acceptedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); } @@ -56,9 +52,7 @@ public class DefaultAcceptedPatternsChecker implements AcceptedPatternsChecker { } public void setAcceptedPatterns(Set<String> patterns) { - if (LOG.isTraceEnabled()) { - LOG.trace("Sets accepted patterns [#0]", patterns); - } + LOG.trace("Sets accepted patterns [{}]", patterns); acceptedPatterns = new HashSet<Pattern>(patterns.size()); for (String pattern : patterns) { acceptedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); @@ -68,9 +62,7 @@ public class DefaultAcceptedPatternsChecker implements AcceptedPatternsChecker { public IsAccepted isAccepted(String value) { for (Pattern acceptedPattern : acceptedPatterns) { if (acceptedPattern.matcher(value).matches()) { - if (LOG.isTraceEnabled()) { - LOG.trace("[#0] matches accepted pattern [#1]", value, acceptedPattern); - } + LOG.trace("[{}] matches accepted pattern [{}]", value, acceptedPattern); return IsAccepted.yes(acceptedPattern.toString()); } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsChecker.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsChecker.java b/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsChecker.java index 8ac60eb..1a2d2a1 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsChecker.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsChecker.java @@ -28,10 +28,8 @@ public class DefaultExcludedPatternsChecker implements ExcludedPatternsChecker { @Inject(value = XWorkConstants.OVERRIDE_EXCLUDED_PATTERNS, required = false) public void setOverrideExcludePatterns(String excludePatterns) { - if (LOG.isWarnEnabled()) { - LOG.warn("Overriding excluded patterns [#0] with [#1], be aware that this affects all instances and safety of your application!", + LOG.warn("Overriding excluded patterns [{}] with [{}], be aware that this affects all instances and safety of your application!", XWorkConstants.OVERRIDE_EXCLUDED_PATTERNS, excludePatterns); - } excludedPatterns = new HashSet<Pattern>(); for (String pattern : TextParseUtil.commaDelimitedStringToSet(excludePatterns)) { excludedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); @@ -40,9 +38,7 @@ public class DefaultExcludedPatternsChecker implements ExcludedPatternsChecker { @Inject(value = XWorkConstants.ADDITIONAL_EXCLUDED_PATTERNS, required = false) public void setAdditionalExcludePatterns(String excludePatterns) { - if (LOG.isDebugEnabled()) { - LOG.debug("Adding additional global patterns [#0] to excluded patterns!", excludePatterns); - } + LOG.debug("Adding additional global patterns [{}] to excluded patterns!", excludePatterns); for (String pattern : TextParseUtil.commaDelimitedStringToSet(excludePatterns)) { excludedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); } @@ -57,9 +53,7 @@ public class DefaultExcludedPatternsChecker implements ExcludedPatternsChecker { } public void setExcludedPatterns(Set<String> patterns) { - if (LOG.isTraceEnabled()) { - LOG.trace("Sets excluded patterns [#0]", patterns); - } + LOG.trace("Sets excluded patterns [{}]", patterns); excludedPatterns = new HashSet<Pattern>(patterns.size()); for (String pattern : patterns) { excludedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); @@ -69,9 +63,7 @@ public class DefaultExcludedPatternsChecker implements ExcludedPatternsChecker { public IsExcluded isExcluded(String value) { for (Pattern excludedPattern : excludedPatterns) { if (excludedPattern.matcher(value).matches()) { - if (LOG.isTraceEnabled()) { - LOG.trace("[#0] matches excluded pattern [#1]", value, excludedPattern); - } + LOG.trace("[{}] matches excluded pattern [{}]", value, excludedPattern); return IsExcluded.yes(excludedPattern); } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/DomHelper.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/DomHelper.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/DomHelper.java index 6e77ecf..3855749 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/DomHelper.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/DomHelper.java @@ -80,16 +80,8 @@ public class DomHelper { try { Class clazz = ObjectFactory.getObjectFactory().getClassInstance(parserProp); factory = (SAXParserFactory) clazz.newInstance(); - } - catch (ClassNotFoundException e) { - if (LOG.isErrorEnabled()) { - LOG.error("Unable to load saxParserFactory set by system property 'xwork.saxParserFactory': #0", e, parserProp); - } - } - catch (Exception e) { - if (LOG.isErrorEnabled()) { - LOG.error("Unable to load saxParserFactory set by system property 'xwork.saxParserFactory': #0", e, parserProp); - } + } catch (Exception e) { + LOG.error("Unable to load saxParserFactory set by system property 'xwork.saxParserFactory': {}", parserProp, e); } } @@ -150,16 +142,8 @@ public class DomHelper { try { Class clazz = ObjectFactory.getObjectFactory().getClassInstance(parserProp); FACTORY = (SAXTransformerFactory) clazz.newInstance(); - } - catch (ClassNotFoundException e) { - if (LOG.isErrorEnabled()) { - LOG.error("Unable to load SAXTransformerFactory set by system property 'xwork.saxTransformerFactory': #0", e, parserProp); - } - } - catch (Exception e) { - if (LOG.isErrorEnabled()) { - LOG.error("Unable to load SAXTransformerFactory set by system property 'xwork.saxTransformerFactory': #0", e, parserProp); - } + } catch (Exception e) { + LOG.error("Unable to load SAXTransformerFactory set by system property 'xwork.saxTransformerFactory': {}", parserProp, e); } } @@ -348,8 +332,8 @@ public class DomHelper { if (dtdMappings != null && dtdMappings.containsKey(publicId)) { String dtdFile = dtdMappings.get(publicId); return new InputSource(ClassLoaderUtil.getResourceAsStream(dtdFile, DomHelper.class)); - } else if (LOG.isWarnEnabled()) { - LOG.warn("Local DTD is missing for publicID: #0 - defined mappings: #1", publicId, dtdMappings); + } else { + LOG.warn("Local DTD is missing for publicID: {} - defined mappings: {}", publicId, dtdMappings); } return null; } @@ -367,8 +351,7 @@ public class DomHelper { @Override public void fatalError(SAXParseException exception) throws SAXException { - LOG.fatal(exception.getMessage() + " at (" + exception.getPublicId() + ":" + - exception.getLineNumber() + ":" + exception.getColumnNumber() + ")", exception); + LOG.fatal("{} at ({}:{}:{})", exception.getMessage(), exception.getPublicId(), exception.getLineNumber(), exception.getColumnNumber(), exception); throw exception; } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java ---------------------------------------------------------------------- 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 943a956..1a46ecf 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 @@ -223,9 +223,9 @@ public class LocalizedTextUtil { } if (devMode) { - LOG.warn("Missing key [#0] in bundles [#1]!", aTextName, localList); - } else if (LOG.isDebugEnabled()) { - LOG.debug("Missing key [#0] in bundles [#1]!", aTextName, localList); + LOG.warn("Missing key [{}] in bundles [{}]!", aTextName, localList); + } else { + LOG.debug("Missing key [{}] in bundles [{}]!", aTextName, localList); } return null; @@ -281,9 +281,7 @@ public class LocalizedTextUtil { bundle = bundlesMap.get(key); } } catch (MissingResourceException e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Missing resource bundle [#0]!", aBundleName); - } + LOG.debug("Missing resource bundle [{}]!", aBundleName, e); } } } @@ -643,15 +641,15 @@ public class LocalizedTextUtil { return formatWithNullDetection(mf, args); } catch (MissingResourceException ex) { if (devMode) { - LOG.warn("Missing key [#0] in bundle [#1]!", aTextName, bundle); - } else if (LOG.isDebugEnabled()) { - LOG.debug("Missing key [#0] in bundle [#1]!", aTextName, bundle); + LOG.warn("Missing key [{}] in bundle [{}]!", aTextName, bundle); + } else { + LOG.debug("Missing key [{}] in bundle [{}]!", aTextName, bundle); } } GetDefaultMessageReturnArg result = getDefaultMessage(aTextName, locale, valueStack, args, defaultMessage); - if (LOG.isWarnEnabled() && unableToFindTextForKey(result)) { - LOG.warn("Unable to find text for key '" + aTextName + "' in ResourceBundles for locale '" + locale + "'"); + if (unableToFindTextForKey(result)) { + LOG.warn("Unable to find text for key '{}' in ResourceBundles for locale '{}'", aTextName, locale); } return result != null ? result.message : null; } @@ -699,9 +697,9 @@ public class LocalizedTextUtil { return formatWithNullDetection(mf, args); } catch (MissingResourceException e) { if (devMode) { - LOG.warn("Missing key [#0] in bundle [#1]!", key, bundleName); - } else if (LOG.isDebugEnabled()) { - LOG.debug("Missing key [#0] in bundle [#1]!", key, bundleName); + LOG.warn("Missing key [{}] in bundle [{}]!", key, bundleName); + } else { + LOG.debug("Missing key [{}] in bundle [{}]!", key, bundleName); } return null; } @@ -821,11 +819,10 @@ public class LocalizedTextUtil { // now, for the true and utter hack, if we're running in tomcat, clear // it's class loader resource cache as well. clearTomcatCache(); - if(context!=null) + if(context!=null) { context.put(RELOADED, true); - if (LOG.isDebugEnabled()) { - LOG.debug("Resource bundles reloaded"); } + LOG.debug("Resource bundles reloaded"); } } catch (Exception e) { LOG.error("Could not reload resource bundles", e); @@ -843,27 +840,19 @@ public class LocalizedTextUtil { if ("org.apache.catalina.loader.WebappClassLoader".equals(cl.getName())) { clearMap(cl, loader, TOMCAT_RESOURCE_ENTRIES_FIELD); } else { - if (LOG.isDebugEnabled()) { - LOG.debug("class loader " + cl.getName() + " is not tomcat loader."); - } + LOG.debug("Class loader {} is not tomcat loader.", cl.getName()); } } catch (NoSuchFieldException nsfe) { if ("org.apache.catalina.loader.WebappClassLoaderBase".equals(cl.getSuperclass().getName())) { - if (LOG.isDebugEnabled()) { - LOG.debug("Base class #0 doesn't contain '#1' field, trying with parent!", nsfe, cl.getName(), TOMCAT_RESOURCE_ENTRIES_FIELD); - } + LOG.debug("Base class {} doesn't contain '{}' field, trying with parent!", cl.getName(), TOMCAT_RESOURCE_ENTRIES_FIELD, nsfe); try { clearMap(cl.getSuperclass(), loader, TOMCAT_RESOURCE_ENTRIES_FIELD); } catch (Exception e) { - if (LOG.isWarnEnabled()) { - LOG.warn("Couldn't clear tomcat cache using #0", e, cl.getSuperclass().getName()); - } + LOG.warn("Couldn't clear tomcat cache using {}", cl.getSuperclass().getName(), e); } } } catch (Exception e) { - if (LOG.isWarnEnabled()) { - LOG.warn("Couldn't clear tomcat cache", e, cl.getName()); - } + LOG.warn("Couldn't clear tomcat cache", cl.getName(), e); } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/URLUtil.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/URLUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/URLUtil.java index db436f1..58ce870 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/URLUtil.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/URLUtil.java @@ -35,9 +35,7 @@ public class URLUtil { */ @Deprecated public static boolean verifyUrl(String url) { - if (LOG.isDebugEnabled()) { - LOG.debug("Checking if url [#0] is valid", url); - } + LOG.debug("Checking if url [{}] is valid", url); if (url == null) { return false; } @@ -52,9 +50,7 @@ public class URLUtil { return true; } catch (MalformedURLException e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Url [#0] is invalid: #1", e, url, e.getMessage()); - } + LOG.debug("Url [{}] is invalid: {}", url, e.getMessage(), e); return false; } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/FileResourceStore.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/FileResourceStore.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/FileResourceStore.java index bab9368..3b2714e 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/FileResourceStore.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/FileResourceStore.java @@ -46,8 +46,7 @@ public final class FileResourceStore implements ResourceStore { return data; } catch (Exception e) { - if (LOG.isDebugEnabled()) - LOG.debug("Unable to read file [#0]", e, pResourceName); + LOG.debug("Unable to read file [{}]", pResourceName, e); return null; } finally { closeQuietly(fis); @@ -63,8 +62,7 @@ public final class FileResourceStore implements ResourceStore { if (is != null) is.close(); } catch (IOException e) { - if (LOG.isErrorEnabled()) - LOG.error("Unable to close file input stream", e); + LOG.error("Unable to close file input stream", e); } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/JarResourceStore.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/JarResourceStore.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/JarResourceStore.java index 19c9524..f7528b0 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/JarResourceStore.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/JarResourceStore.java @@ -51,8 +51,7 @@ public class JarResourceStore implements ResourceStore { return out.toByteArray(); } catch (Exception e) { - if (LOG.isDebugEnabled()) - LOG.debug("Unable to read file [#0] from [#1]", e, pResourceName, file.getName()); + LOG.debug("Unable to read file [{}] from [{}]", pResourceName, file.getName(), e); return null; } finally { closeQuietly(in); @@ -76,8 +75,7 @@ public class JarResourceStore implements ResourceStore { if (is != null) is.close(); } catch (IOException e) { - if (LOG.isErrorEnabled()) - LOG.error("Unable to close input stream", e); + LOG.error("Unable to close input stream", e); } } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/ReloadingClassLoader.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/ReloadingClassLoader.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/ReloadingClassLoader.java index 7c46ee6..3d17ca4 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/ReloadingClassLoader.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/ReloadingClassLoader.java @@ -66,10 +66,12 @@ public class ReloadingClassLoader extends ClassLoader { } catch (RuntimeException e) { // see WW-3121 // TODO: Fix this for a reloading mechanism to be marked as stable - if (root != null) - LOG.error("Exception while trying to build the ResourceStore for URL [#0]", e, root.toString()); - else + if (root != null) { + LOG.error("Exception while trying to build the ResourceStore for URL [{}]", root.toString(), e); + } + else { LOG.error("Exception while trying to get root resource from class loader", e); + } LOG.error("Consider setting struts.convention.classes.reload=false"); throw e; } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/DefaultClassFinder.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/DefaultClassFinder.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/DefaultClassFinder.java index 44d4eb2..80f205a 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/DefaultClassFinder.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/DefaultClassFinder.java @@ -85,8 +85,7 @@ public class DefaultClassFinder implements ClassFinder { } } } catch (Exception e) { - if (LOG.isErrorEnabled()) - LOG.error("Unable to read URL [#0]", e, location.toExternalForm()); + LOG.error("Unable to read URL [{}]", location.toExternalForm(), e); } } @@ -95,8 +94,7 @@ public class DefaultClassFinder implements ClassFinder { if (classNameFilter.test(className)) readClassDef(className); } catch (Throwable e) { - if (LOG.isErrorEnabled()) - LOG.error("Unable to read class [#0]", e, className); + LOG.error("Unable to read class [{}]", className, e); } } } @@ -189,8 +187,7 @@ public class DefaultClassFinder implements ClassFinder { classes.add(clazz); } } catch (Throwable e) { - if (LOG.isErrorEnabled()) - LOG.error("Error loading class [#0]", e, classInfo.getName()); + LOG.error("Error loading class [{}]", classInfo.getName(), e); classesNotLoaded.add(classInfo.getName()); } } @@ -220,8 +217,7 @@ public class DefaultClassFinder implements ClassFinder { } } } catch (Throwable e) { - if (LOG.isErrorEnabled()) - LOG.error("Error loading class [#0]", e, classInfo.getName()); + LOG.error("Error loading class [{}]", classInfo.getName(), e); classesNotLoaded.add(classInfo.getName()); } } @@ -251,8 +247,7 @@ public class DefaultClassFinder implements ClassFinder { } } } catch (Throwable e) { - if (LOG.isErrorEnabled()) - LOG.error("Error loading class [#0]", e, classInfo.getName()); + LOG.error("Error loading class [{}]", classInfo.getName(), e); classesNotLoaded.add(classInfo.getName()); } } @@ -282,8 +277,7 @@ public class DefaultClassFinder implements ClassFinder { } } } catch (Throwable e) { - if (LOG.isErrorEnabled()) - LOG.error("Error loading class [#0]", e, classInfo.getName()); + LOG.error("Error loading class [{}]", classInfo.getName(), e); classesNotLoaded.add(classInfo.getName()); } } @@ -302,8 +296,7 @@ public class DefaultClassFinder implements ClassFinder { classes.add(classInfo.get()); } } catch (Throwable e) { - if (LOG.isErrorEnabled()) - LOG.error("Error loading class [#0]", e, classInfo.getName()); + LOG.error("Error loading class [{}]", classInfo.getName(), e); classesNotLoaded.add(classInfo.getName()); } } @@ -319,8 +312,7 @@ public class DefaultClassFinder implements ClassFinder { classes.add(classInfo.get()); } } catch (Throwable e) { - if (LOG.isErrorEnabled()) - LOG.error("Error loading class [#0]", e, classInfo.getName()); + LOG.error("Error loading class [{}]", classInfo.getName(), e); classesNotLoaded.add(classInfo.getName()); } } @@ -334,8 +326,7 @@ public class DefaultClassFinder implements ClassFinder { try { classes.add(classInfo.get()); } catch (Throwable e) { - if (LOG.isErrorEnabled()) - LOG.error("Error loading class [#0]", e, classInfo.getName()); + LOG.error("Error loading class [{}]", classInfo.getName(), e); classesNotLoaded.add(classInfo.getName()); } } @@ -352,8 +343,7 @@ public class DefaultClassFinder implements ClassFinder { urls.add(url); } } catch (IOException ioe) { - if (LOG.isErrorEnabled()) - LOG.error("Could not read driectory [#0]", ioe, dirName); + LOG.error("Could not read directory [{}]", dirName, ioe); } } @@ -397,9 +387,9 @@ public class DefaultClassFinder implements ClassFinder { } finally { in.close(); } - } else if (LOG.isDebugEnabled()) - LOG.debug("Unable to read [#0]", location.toExternalForm()); - + } else { + LOG.debug("Unable to read [{}]", location.toExternalForm()); + } return Collections.emptyList(); } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ResourceFinder.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ResourceFinder.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ResourceFinder.java index ffda507..8e8d2a6 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ResourceFinder.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ResourceFinder.java @@ -836,9 +836,7 @@ public class ResourceFinder { } } catch (Exception e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Got exception loading resources for #0", e, uri); - } + LOG.debug("Got exception loading resources for {}", uri, e); } } @@ -871,9 +869,7 @@ public class ResourceFinder { } } catch (Exception e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Got exception search for subpackages for #0", e, uri); - } + LOG.debug("Got exception search for subpackages for {}", uri, e); } } @@ -906,9 +902,7 @@ public class ResourceFinder { result.put(location, convertPathsToPackages(resources)); } } catch (Exception e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Got exception finding subpackages for #0", e, uri); - } + LOG.debug("Got exception finding subpackages for {}", uri, e); } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/UrlSet.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/UrlSet.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/UrlSet.java index c38d5d5..f5de6fd 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/UrlSet.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/UrlSet.java @@ -237,9 +237,9 @@ public class UrlSet { //build a URL pointing to the jar, instead of the META-INF dir url = new URL(StringUtils.substringBefore(externalForm, "META-INF")); list.add(url); - } else if (LOG.isDebugEnabled()) - LOG.debug("Ignoring URL [#0] because it is not a jar", url.toExternalForm()); - + } else { + LOG.debug("Ignoring URL [{}] because it is not a jar", url.toExternalForm()); + } } //usually the "classes" dir @@ -264,17 +264,14 @@ public class UrlSet { //build a URL pointing to the jar, instead of the META-INF dir url = new URL(StringUtils.substringBefore(externalForm, "META-INF")); list.add(url); - } else if (LOG.isDebugEnabled()) - LOG.debug("Ignoring URL [#0] because it is not a valid protocol", url.toExternalForm()); - + } else { + LOG.debug("Ignoring URL [{}] because it is not a valid protocol", url.toExternalForm()); + } } return list; } public static interface FileProtocolNormalizer { - URL normalizeToFileProtocol(URL url); - } - } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManager.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManager.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManager.java index b0c93d7..42d2a38 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManager.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManager.java @@ -126,15 +126,11 @@ public class DefaultFileManager implements FileManager { } else if ("file".equals(url.getProtocol())) { return url; // it's already a file } else { - if (LOG.isWarnEnabled()) { - LOG.warn("Could not normalize URL [#0] to file protocol!", url.toString()); - } + LOG.warn("Could not normalize URL [{}] to file protocol!", url); return null; } } catch (MalformedURLException e) { - if (LOG.isWarnEnabled()) { - LOG.warn("Error normalizing URL [#0] to file protocol!", e, url.toString()); - } + LOG.warn("Error normalizing URL [{}] to file protocol!", url, e); return null; } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactory.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactory.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactory.java index 741d297..7c872f3 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactory.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactory.java @@ -40,24 +40,18 @@ public class DefaultFileManagerFactory implements FileManagerFactory { public FileManager getFileManager() { FileManager fileManager = lookupFileManager(); if (fileManager != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("Using FileManager implementation [#0]", fileManager.getClass().getSimpleName()); - } + LOG.debug("Using FileManager implementation [{}]", fileManager.getClass().getSimpleName()); fileManager.setReloadingConfigs(reloadingConfigs); return fileManager; } - if (LOG.isDebugEnabled()) { - LOG.debug("Using default implementation of FileManager provided under name [system]: #0", systemFileManager.getClass().getSimpleName()); - } + LOG.debug("Using default implementation of FileManager provided under name [system]: {}", systemFileManager.getClass().getSimpleName()); systemFileManager.setReloadingConfigs(reloadingConfigs); return systemFileManager; } private FileManager lookupFileManager() { Set<String> names = container.getInstanceNames(FileManager.class); - if (LOG.isDebugEnabled()) { - LOG.debug("Found following implementations of FileManager interface: #0", names.toString()); - } + LOG.debug("Found following implementations of FileManager interface: {}", names); Set<FileManager> internals = new HashSet<FileManager>(); Set<FileManager> users = new HashSet<FileManager>(); for (String fmName : names) { @@ -70,15 +64,11 @@ public class DefaultFileManagerFactory implements FileManagerFactory { } for (FileManager fm : users) { if (fm.support()) { - if (LOG.isDebugEnabled()) { - LOG.debug("Using FileManager implementation [#0]", fm.getClass().getSimpleName()); - } + LOG.debug("Using FileManager implementation [{}]", fm.getClass().getSimpleName()); return fm; } } - if (LOG.isDebugEnabled()) { - LOG.debug("No user defined FileManager, looking up for internal implementations!"); - } + LOG.debug("No user defined FileManager, looking up for internal implementations!"); for (FileManager fm : internals) { if (fm.support()) { return fm; http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/JarEntryRevision.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/JarEntryRevision.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/JarEntryRevision.java index b2c9684..4b962af 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/JarEntryRevision.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/JarEntryRevision.java @@ -35,11 +35,10 @@ public class JarEntryRevision extends Revision { separatorIndex = fileName.lastIndexOf(JAR_FILE_EXTENSION_END); } if (separatorIndex == -1) { - if (LOG.isWarnEnabled()) { - LOG.warn("Could not find end of jar file!"); - } + LOG.warn("Could not find end of jar file!"); return null; } + // Split file name jarFileName = fileName.substring(0, separatorIndex); int index = separatorIndex + JAR_FILE_NAME_SEPARATOR.length(); @@ -54,9 +53,7 @@ public class JarEntryRevision extends Revision { return null; } } catch (Throwable e) { - if (LOG.isWarnEnabled()) { - LOG.warn("Could not create JarEntryRevision for [#0]!", e, jarFileName); - } + LOG.warn("Could not create JarEntryRevision for [{}]!", jarFileName, e); return null; } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java index 3f98023..7c96ae3 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java @@ -174,7 +174,7 @@ public class DefaultValidatorFactory implements ValidatorFactory { } } } catch (Exception ex) { - LOG.error("Unable to load #0", ex, u.toString()); + LOG.error("Unable to load {}", u, ex); } } } catch (IOException e) { http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/ExpressionValidator.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/ExpressionValidator.java b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/ExpressionValidator.java index 15a5858..d7f129b 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/ExpressionValidator.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/ExpressionValidator.java @@ -70,13 +70,11 @@ public class ExpressionValidator extends ValidatorSupport { if ((obj != null) && (obj instanceof Boolean)) { answer = (Boolean) obj; } else { - log.warn("Got result of [#0] when trying to get Boolean.", obj); + log.warn("Got result of [{}] when trying to get Boolean.", obj); } if (!answer) { - if (log.isDebugEnabled()) { - log.debug("Validation failed on expression [#0] with validated object [#1]", expression, object); - } + log.debug("Validation failed on expression [{}] with validated object [{}]", expression, object); addActionError(object); } } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RangeValidatorSupport.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RangeValidatorSupport.java b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RangeValidatorSupport.java index 183ea65..39c0e86 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RangeValidatorSupport.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RangeValidatorSupport.java @@ -76,9 +76,7 @@ public abstract class RangeValidatorSupport<T extends Comparable> extends FieldV } public void setMinExpression(String minExpression) { - if (LOG.isDebugEnabled()) { - LOG.debug("${minExpression} was defined as [#0]", minExpression); - } + LOG.debug("${minExpression} was defined as [{}]", minExpression); this.minExpression = minExpression; } @@ -97,9 +95,7 @@ public abstract class RangeValidatorSupport<T extends Comparable> extends FieldV } public void setMaxExpression(String maxExpression) { - if (LOG.isDebugEnabled()) { - LOG.debug("${maxExpression} was defined as [#0]", maxExpression); - } + LOG.debug("${maxExpression} was defined as [{}]", maxExpression); this.maxExpression = maxExpression; } http://git-wip-us.apache.org/repos/asf/struts/blob/8e877115/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RegexFieldValidator.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RegexFieldValidator.java b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RegexFieldValidator.java index 778c522..a107387 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RegexFieldValidator.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/RegexFieldValidator.java @@ -95,9 +95,8 @@ public class RegexFieldValidator extends FieldValidatorSupport { // if there is no value - don't do comparison // if a value is required, a required validator should be added to the field String regexToUse = getRegex(); - if (LOG.isDebugEnabled()) { - LOG.debug("Defined regexp as [#0]", regexToUse); - } + LOG.debug("Defined regexp as [{}]", regexToUse); + if (value == null || regexToUse == null) { return; }