http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkCollectionPropertyAccessor.java ---------------------------------------------------------------------- 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 a656634..a1e7536 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 @@ -21,19 +21,17 @@ import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer; import com.opensymphony.xwork2.conversion.impl.XWorkConverter; import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.ognl.OgnlUtil; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; import com.opensymphony.xwork2.util.reflection.ReflectionContextState; - import ognl.ObjectPropertyAccessor; import ognl.OgnlException; import ognl.OgnlRuntime; import ognl.SetPropertyAccessor; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -42,7 +40,6 @@ import java.util.Map; public class XWorkCollectionPropertyAccessor extends SetPropertyAccessor { private static final Logger LOG = LogManager.getLogger(XWorkCollectionPropertyAccessor.class); - private static final String CONTEXT_COLLECTION_MAP = "xworkCollectionPropertyAccessorContextSetMap"; public static final String KEY_PROPERTY_FOR_CREATION = "makeNew"; @@ -87,18 +84,13 @@ public class XWorkCollectionPropertyAccessor extends SetPropertyAccessor { * @see ognl.PropertyAccessor#getProperty(java.util.Map, Object, Object) */ @Override - public Object getProperty(Map context, Object target, Object key) - throws OgnlException { - - if (LOG.isDebugEnabled()) { - LOG.debug("Entering getProperty()"); - } + public Object getProperty(Map context, Object target, Object key) throws OgnlException { + LOG.trace("Entering getProperty()"); //check if it is a generic type property. //if so, return the value from the //superclass which will determine this. - if (!ReflectionContextState.isGettingByKeyProperty(context) - && !key.equals(KEY_PROPERTY_FOR_CREATION)) { + if (!ReflectionContextState.isGettingByKeyProperty(context) && !key.equals(KEY_PROPERTY_FOR_CREATION)) { return super.getProperty(context, target, key); } else { //reset context property @@ -119,17 +111,15 @@ public class XWorkCollectionPropertyAccessor extends SetPropertyAccessor { ReflectionContextState.updateCurrentPropertyPath(context, key); return super.getProperty(context, target, key); } - - + //get the key property to index the //collection with from the ObjectTypeDeterminer - String keyProperty = objectTypeDeterminer - .getKeyProperty(lastBeanClass, lastPropertyClass); + String keyProperty = objectTypeDeterminer.getKeyProperty(lastBeanClass, lastPropertyClass); //get the collection class of the Class collClass = objectTypeDeterminer.getElementClass(lastBeanClass, lastPropertyClass, key); - Class keyType = null; + Class keyType; Class toGetTypeFrom = (collClass != null) ? collClass : c.iterator().next().getClass(); try { keyType = OgnlRuntime.getPropertyDescriptor(toGetTypeFrom, keyProperty).getPropertyType(); @@ -139,7 +129,7 @@ public class XWorkCollectionPropertyAccessor extends SetPropertyAccessor { if (ReflectionContextState.isCreatingNullObjects(context)) { - Map collMap = getSetMap(context, c, keyProperty, collClass); + Map collMap = getSetMap(context, c, keyProperty); if (key.toString().equals(KEY_PROPERTY_FOR_CREATION)) { //this should return the XWorkList //for this set that contains new entries @@ -171,7 +161,6 @@ public class XWorkCollectionPropertyAccessor extends SetPropertyAccessor { } catch (Exception exc) { throw new OgnlException("Error adding new element to collection", exc); - } } @@ -194,21 +183,15 @@ public class XWorkCollectionPropertyAccessor extends SetPropertyAccessor { * Gets an indexed Map by a given key property with the key being * the value of the property and the value being the */ - private Map getSetMap(Map context, Collection collection, String property, Class valueClass) - throws OgnlException { - if (LOG.isDebugEnabled()) { - LOG.debug("getting set Map"); - } - + private Map getSetMap(Map context, Collection collection, String property) throws OgnlException { + LOG.trace("getting set Map"); + String path = ReflectionContextState.getCurrentPropertyPath(context); - Map map = ReflectionContextState.getSetMap(context, - path); + Map map = ReflectionContextState.getSetMap(context, path); if (map == null) { - if (LOG.isDebugEnabled()) { - LOG.debug("creating set Map"); - } - + LOG.trace("creating set Map"); + map = new HashMap(); map.put(null, new SurrugateList(collection)); for (Object currTest : collection) { @@ -238,9 +221,7 @@ public class XWorkCollectionPropertyAccessor extends SetPropertyAccessor { } @Override - public void setProperty(Map context, Object target, Object name, Object value) - throws OgnlException { - + public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { Class lastClass = (Class) context.get(XWorkConverter.LAST_BEAN_CLASS_ACCESSED); String lastProperty = (String) context.get(XWorkConverter.LAST_BEAN_PROPERTY_ACCESSED); Class convertToClass = objectTypeDeterminer.getElementClass(lastClass, lastProperty, name);
http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkEnumerationAccessor.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkEnumerationAccessor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkEnumerationAccessor.java index 88e6408..84745e4 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkEnumerationAccessor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkEnumerationAccessor.java @@ -29,7 +29,6 @@ public class XWorkEnumerationAccessor extends EnumerationPropertyAccessor { ObjectPropertyAccessor opa = new ObjectPropertyAccessor(); - @Override public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { opa.setProperty(context, target, name, value); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkIteratorPropertyAccessor.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkIteratorPropertyAccessor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkIteratorPropertyAccessor.java index 7afe3f5..2a6184b 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkIteratorPropertyAccessor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkIteratorPropertyAccessor.java @@ -29,7 +29,6 @@ public class XWorkIteratorPropertyAccessor extends IteratorPropertyAccessor { ObjectPropertyAccessor opa = new ObjectPropertyAccessor(); - @Override public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { opa.setProperty(context, target, name, value); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java index 6dab13b..6201dae 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java @@ -72,17 +72,15 @@ public class XWorkListPropertyAccessor extends ListPropertyAccessor { } @Override - public Object getProperty(Map context, Object target, Object name) - throws OgnlException { + public Object getProperty(Map context, Object target, Object name) throws OgnlException { if (ReflectionContextState.isGettingByKeyProperty(context) || name.equals(XWorkCollectionPropertyAccessor.KEY_PROPERTY_FOR_CREATION)) { return _sAcc.getProperty(context, target, name); - } else if (name instanceof String) { + } else if (name instanceof String) { return super.getProperty(context, target, name); } ReflectionContextState.updateCurrentPropertyPath(context, name); - //System.out.println("Entering XWorkListPropertyAccessor. Name: " + name); Class lastClass = (Class) context.get(XWorkConverter.LAST_BEAN_CLASS_ACCESSED); String lastProperty = (String) context.get(XWorkConverter.LAST_BEAN_PROPERTY_ACCESSED); @@ -90,7 +88,6 @@ public class XWorkListPropertyAccessor extends ListPropertyAccessor { && ReflectionContextState.isCreatingNullObjects(context) && objectTypeDeterminer.shouldCreateIfNew(lastClass,lastProperty,target,null,true)) { - //System.out.println("Getting index from List"); List list = (List) target; int index = ((Number) name).intValue(); int listSize = list.size(); @@ -100,12 +97,10 @@ public class XWorkListPropertyAccessor extends ListPropertyAccessor { } Class beanClass = objectTypeDeterminer.getElementClass(lastClass, lastProperty, name); if (listSize <= index) { - Object result = null; + Object result; for (int i = listSize; i < index; i++) { - list.add(null); - } try { list.add(index, result = objectFactory.buildBean(beanClass, context)); @@ -114,7 +109,7 @@ public class XWorkListPropertyAccessor extends ListPropertyAccessor { } return result; } else if (list.get(index) == null) { - Object result = null; + Object result; try { list.set(index, result = objectFactory.buildBean(beanClass, context)); } catch (Exception exc) { http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkMapPropertyAccessor.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkMapPropertyAccessor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkMapPropertyAccessor.java index d752216..e30f07e 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkMapPropertyAccessor.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkMapPropertyAccessor.java @@ -20,11 +20,11 @@ import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer; import com.opensymphony.xwork2.conversion.impl.XWorkConverter; import com.opensymphony.xwork2.inject.Inject; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; import com.opensymphony.xwork2.util.reflection.ReflectionContextState; import ognl.MapPropertyAccessor; import ognl.OgnlException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.Map; @@ -38,8 +38,7 @@ public class XWorkMapPropertyAccessor extends MapPropertyAccessor { private static final Logger LOG = LogManager.getLogger(XWorkMapPropertyAccessor.class); - private static final String[] INDEX_ACCESS_PROPS = new String[] - {"size", "isEmpty", "keys", "values"}; + private static final String[] INDEX_ACCESS_PROPS = new String[]{"size", "isEmpty", "keys", "values"}; private XWorkConverter xworkConverter; private ObjectFactory objectFactory; @@ -62,10 +61,7 @@ public class XWorkMapPropertyAccessor extends MapPropertyAccessor { @Override public Object getProperty(Map context, Object target, Object name) throws OgnlException { - - if (LOG.isDebugEnabled()) { - LOG.debug("Entering getProperty ("+context+","+target+","+name+")"); - } + LOG.trace("Entering getProperty ({},{},{})", context, target, name); ReflectionContextState.updateCurrentPropertyPath(context, name); // if this is one of the regular index access @@ -79,7 +75,7 @@ public class XWorkMapPropertyAccessor extends MapPropertyAccessor { try{ result = super.getProperty(context, target, name); - } catch(ClassCastException ex){ + } catch (ClassCastException ex) { } if (result == null) { @@ -103,9 +99,7 @@ public class XWorkMapPropertyAccessor extends MapPropertyAccessor { result = objectFactory.buildBean(valueClass, context); map.put(key, result); } catch (Exception exc) { - } - } } return result; @@ -127,16 +121,14 @@ public class XWorkMapPropertyAccessor extends MapPropertyAccessor { @Override public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { - if (LOG.isDebugEnabled()) { - LOG.debug("Entering setProperty("+context+","+target+","+name+","+value+")"); - } - + LOG.trace("Entering setProperty({},{},{},{})", context, target, name, value); + Object key = getKey(context, name); Map map = (Map) target; map.put(key, getValue(context, value)); } - private Object getValue(Map context, Object value) { + private Object getValue(Map context, Object value) { Class lastClass = (Class) context.get(XWorkConverter.LAST_BEAN_CLASS_ACCESSED); String lastProperty = (String) context.get(XWorkConverter.LAST_BEAN_PROPERTY_ACCESSED); if (lastClass == null || lastProperty == null) { @@ -147,7 +139,7 @@ public class XWorkMapPropertyAccessor extends MapPropertyAccessor { return value; // nothing is specified, we assume it will be the value passed in. } return xworkConverter.convertValue(context, value, elementClass); -} + } private Object getKey(Map context, Object name) { Class lastClass = (Class) context.get(XWorkConverter.LAST_BEAN_CLASS_ACCESSED); @@ -163,7 +155,6 @@ public class XWorkMapPropertyAccessor extends MapPropertyAccessor { } return xworkConverter.convertValue(context, name, keyClass); - } } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/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 55b6280..7a05bc5 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 @@ -15,21 +15,16 @@ */ package com.opensymphony.xwork2.ognl.accessor; +import com.opensymphony.xwork2.util.reflection.ReflectionContextState; +import ognl.*; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.beans.PropertyDescriptor; import java.util.Arrays; import java.util.Collection; import java.util.Map; -import ognl.MethodFailedException; -import ognl.ObjectMethodAccessor; -import ognl.OgnlContext; -import ognl.OgnlRuntime; -import ognl.PropertyAccessor; - -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import com.opensymphony.xwork2.util.reflection.ReflectionContextState; - /** * Allows methods to be executed under normal cirumstances, except when {@link ReflectionContextState#DENY_METHOD_EXECUTION} @@ -59,9 +54,8 @@ public class XWorkMethodAccessor extends ObjectMethodAccessor { //this if statement ensures that ognl //statements of the form someBean.mySet('keyPropVal') //return the set element with value of the keyProp given - - if (objects.length==1 - && context instanceof OgnlContext) { + + if (objects.length == 1 && context instanceof OgnlContext) { try { OgnlContext ogContext=(OgnlContext)context; if (OgnlRuntime.hasSetProperty(ogContext, object, string)) { @@ -90,11 +84,7 @@ public class XWorkMethodAccessor extends ObjectMethodAccessor { } //HACK - we pass indexed method access i.e. setXXX(A,B) pattern - if ( - (objects.length == 2 && string.startsWith("set")) - || - (objects.length == 1 && string.startsWith("get")) - ) { + if ((objects.length == 2 && string.startsWith("set")) || (objects.length == 1 && string.startsWith("get"))) { Boolean exec = (Boolean) context.get(ReflectionContextState.DENY_INDEXED_ACCESS_EXECUTION); boolean e = ((exec == null) ? false : exec.booleanValue()); if (!e) { @@ -111,18 +101,17 @@ public class XWorkMethodAccessor extends ObjectMethodAccessor { } } - private Object callMethodWithDebugInfo(Map context, Object object, String methodName, - Object[] objects) throws MethodFailedException { - try { - return super.callMethod(context, object, methodName, objects); + private Object callMethodWithDebugInfo(Map context, Object object, String methodName, Object[] objects) throws MethodFailedException { + try { + return super.callMethod(context, object, methodName, objects); } catch(MethodFailedException e) { if (LOG.isDebugEnabled()) { if (!(e.getReason() instanceof NoSuchMethodException)) { // the method exists on the target object, but something went wrong - LOG.debug( "Error calling method through OGNL: object: [{}] method: [{}] args: [{}]", 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; } } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/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 deb7c03..00e9f79 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 @@ -3,8 +3,8 @@ package com.opensymphony.xwork2.security; import com.opensymphony.xwork2.XWorkConstants; import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.util.TextParseUtil; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.Arrays; import java.util.HashSet; @@ -29,7 +29,7 @@ public class DefaultAcceptedPatternsChecker implements AcceptedPatternsChecker { public void setOverrideAcceptedPatterns(String acceptablePatterns) { 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>(); + acceptedPatterns = new HashSet<>(); for (String pattern : TextParseUtil.commaDelimitedStringToSet(acceptablePatterns)) { acceptedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); } @@ -48,12 +48,12 @@ public class DefaultAcceptedPatternsChecker implements AcceptedPatternsChecker { } public void setAcceptedPatterns(String[] additionalPatterns) { - setAcceptedPatterns(new HashSet<String>(Arrays.asList(additionalPatterns))); + setAcceptedPatterns(new HashSet<>(Arrays.asList(additionalPatterns))); } public void setAcceptedPatterns(Set<String> patterns) { LOG.trace("Sets accepted patterns [{}]", patterns); - acceptedPatterns = new HashSet<Pattern>(patterns.size()); + acceptedPatterns = new HashSet<>(patterns.size()); for (String pattern : patterns) { acceptedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/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 1a2d2a1..f6d48cd 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 @@ -1,10 +1,10 @@ package com.opensymphony.xwork2.security; -import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.XWorkConstants; import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.util.TextParseUtil; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.Arrays; import java.util.HashSet; @@ -49,12 +49,12 @@ public class DefaultExcludedPatternsChecker implements ExcludedPatternsChecker { } public void setExcludedPatterns(String[] patterns) { - setExcludedPatterns(new HashSet<String>(Arrays.asList(patterns))); + setExcludedPatterns(new HashSet<>(Arrays.asList(patterns))); } public void setExcludedPatterns(Set<String> patterns) { LOG.trace("Sets excluded patterns [{}]", patterns); - excludedPatterns = new HashSet<Pattern>(patterns.size()); + excludedPatterns = new HashSet<>(patterns.size()); for (String pattern : patterns) { excludedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java ---------------------------------------------------------------------- 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 718480f..f1137d9 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 @@ -17,6 +17,7 @@ package com.opensymphony.xwork2.spring; import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.inject.Inject; +import org.apache.commons.lang3.BooleanUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.BeansException; @@ -44,7 +45,7 @@ public class SpringObjectFactory extends ObjectFactory implements ApplicationCon protected ApplicationContext appContext; protected AutowireCapableBeanFactory autoWiringFactory; protected int autowireStrategy = AutowireCapableBeanFactory.AUTOWIRE_BY_NAME; - private final Map<String, Object> classes = new HashMap<String, Object>(); + private final Map<String, Object> classes = new HashMap<>(); private boolean useClassCache = true; private boolean alwaysRespectAutowireStrategy = false; /** @@ -62,7 +63,7 @@ public class SpringObjectFactory extends ObjectFactory implements ApplicationCon @Inject(value = "enableAopSupport", required = false) public void setEnableAopSupport(String enableAopSupport) { - this.enableAopSupport = Boolean.parseBoolean(enableAopSupport); + this.enableAopSupport = BooleanUtils.toBoolean(enableAopSupport); } /** @@ -203,8 +204,7 @@ public class SpringObjectFactory extends ObjectFactory implements ApplicationCon */ public Object autoWireBean(Object bean, AutowireCapableBeanFactory autoWiringFactory) { if (autoWiringFactory != null) { - autoWiringFactory.autowireBeanProperties(bean, - autowireStrategy, false); + autoWiringFactory.autowireBeanProperties(bean, autowireStrategy, false); } injectApplicationContext(bean); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringProxyableObjectFactory.java ---------------------------------------------------------------------- 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 3f701a1..f249f5f 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 @@ -36,7 +36,7 @@ public class SpringProxyableObjectFactory extends SpringObjectFactory { private static final Logger LOG = LogManager.getLogger(SpringProxyableObjectFactory.class); - private List<String> skipBeanNames = new ArrayList<String>(); + private List<String> skipBeanNames = new ArrayList<>(); @Override public Object buildBean(String beanName, Map<String, Object> extraContext) throws Exception { http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptor.java ---------------------------------------------------------------------- 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 611a1a3..fe02ca5 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 @@ -20,8 +20,8 @@ import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; import com.opensymphony.xwork2.spring.SpringObjectFactory; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -97,9 +97,7 @@ public class ActionAutowiringInterceptor extends AbstractInterceptor implements WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (applicationContext == null) { - if (LOG.isWarnEnabled()) { - LOG.warn("ApplicationContext could not be found. Action classes will not be autowired."); - } + LOG.warn("ApplicationContext could not be found. Action classes will not be autowired."); } else { setApplicationContext(applicationContext); factory = new SpringObjectFactory(); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/AnnotationUtils.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/AnnotationUtils.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/AnnotationUtils.java index c9f2863..08cae03 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/AnnotationUtils.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/AnnotationUtils.java @@ -118,14 +118,14 @@ public class AnnotationUtils { * method {@link AnnotatedElement}s matching the specified {@link Annotation}s */ public static Collection<Method> getAnnotatedMethods(Class clazz, Class<? extends Annotation>... annotation){ - Collection<Method> toReturn = new HashSet<Method>(); - - for(Method m : clazz.getMethods()){ - if( ArrayUtils.isNotEmpty(annotation) && isAnnotatedBy(m, annotation) ){ - toReturn.add(m); - }else if( ArrayUtils.isEmpty(annotation) && ArrayUtils.isNotEmpty(m.getAnnotations())){ - toReturn.add(m); - } + Collection<Method> toReturn = new HashSet<>(); + + for (Method m : clazz.getMethods()) { + if (org.apache.commons.lang3.ArrayUtils.isNotEmpty(annotation) && isAnnotatedBy(m, annotation)) { + toReturn.add(m); + } else if (org.apache.commons.lang3.ArrayUtils.isEmpty(annotation) && org.apache.commons.lang3.ArrayUtils.isNotEmpty(m.getAnnotations())) { + toReturn.add(m); + } } return toReturn; @@ -136,7 +136,9 @@ public class AnnotationUtils { * @see AnnotatedElement */ public static boolean isAnnotatedBy(AnnotatedElement annotatedElement, Class<? extends Annotation>... annotation) { - if(ArrayUtils.isEmpty(annotation)) return false; + if (org.apache.commons.lang3.ArrayUtils.isEmpty(annotation)) { + return false; + } for( Class<? extends Annotation> c : annotation ){ if( annotatedElement.isAnnotationPresent(c) ) return true; @@ -173,20 +175,21 @@ public class AnnotationUtils { * Returns the annotation on the given class or the package of the class. This searchs up the * class hierarchy and the package hierarchy for the closest match. * - * @param klass The class to search for the annotation. + * @param clazz The class to search for the annotation. * @param annotationClass The Class of the annotation. * @return The annotation or null. */ - public static <T extends Annotation> T findAnnotation(Class<?> klass, Class<T> annotationClass) { - T ann = klass.getAnnotation(annotationClass); - while (ann == null && klass != null) { - ann = klass.getAnnotation(annotationClass); - if (ann == null) - ann = klass.getPackage().getAnnotation(annotationClass); + public static <T extends Annotation> T findAnnotation(Class<?> clazz, Class<T> annotationClass) { + T ann = clazz.getAnnotation(annotationClass); + while (ann == null && clazz != null) { + ann = clazz.getAnnotation(annotationClass); + if (ann == null) { + ann = clazz.getPackage().getAnnotation(annotationClass); + } if (ann == null) { - klass = klass.getSuperclass(); - if (klass != null ) { - ann = klass.getAnnotation(annotationClass); + clazz = clazz.getSuperclass(); + if (clazz != null) { + ann = clazz.getAnnotation(annotationClass); } } } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/ArrayUtils.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/ArrayUtils.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/ArrayUtils.java index 0da1598..99f4ab6 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/ArrayUtils.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/ArrayUtils.java @@ -22,7 +22,9 @@ import java.util.Set; /** * @author Dan Oxlade, dan d0t oxlade at gmail d0t c0m + * @deprecated Can be replaced eith ArrayUtils from lang3 package --> org.apache.commons.lang3.ArrayUtils */ +@Deprecated public class ArrayUtils { public static boolean isEmpty(Object[] array) { http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java index 77c4685..919f5af 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java @@ -48,7 +48,7 @@ public class ClassLoaderUtil { */ public static Iterator<URL> getResources(String resourceName, Class callingClass, boolean aggregate) throws IOException { - AggregateIterator<URL> iterator = new AggregateIterator<URL>(); + AggregateIterator<URL> iterator = new AggregateIterator<>(); iterator.addEnumeration(Thread.currentThread().getContextClassLoader().getResources(resourceName)); @@ -182,7 +182,7 @@ public class ClassLoaderUtil { */ static class AggregateIterator<E> implements Iterator<E> { - LinkedList<Enumeration<E>> enums = new LinkedList<Enumeration<E>>(); + LinkedList<Enumeration<E>> enums = new LinkedList<>(); Enumeration<E> cur = null; E next = null; Set<E> loaded = new HashSet<E>(); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassPathFinder.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassPathFinder.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassPathFinder.java index a8ebca2..5743885 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassPathFinder.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/ClassPathFinder.java @@ -48,8 +48,8 @@ public class ClassPathFinder { * The PatternMatcher implementation to use */ private PatternMatcher<int[]> patternMatcher = new WildcardHelper(); - - private Vector<String> compared = new Vector<String>(); + + private Vector<String> compared = new Vector<>(); /** * retrieves the pattern in use @@ -74,13 +74,13 @@ public class ClassPathFinder { * @return Vector<String> containing matching filenames */ public Vector<String> findMatches() { - Vector<String> matches = new Vector<String>(); + Vector<String> matches = new Vector<>(); URLClassLoader cl = getURLClassLoader(); if (cl == null ) { throw new XWorkException("unable to attain an URLClassLoader") ; } URL[] parentUrls = cl.getURLs(); - compiledPattern = (int[]) patternMatcher.compilePattern(pattern); + compiledPattern = patternMatcher.compilePattern(pattern); for (URL url : parentUrls) { if (!"file".equals(url.getProtocol())) { continue ; @@ -105,8 +105,8 @@ public class ClassPathFinder { if (entries == null ) { return null; } - - Vector<String> matches = new Vector<String>(); + + Vector<String> matches = new Vector<>(); for (String listEntry : entries) { File tempFile ; if (!"".equals(prefix) ) { http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/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 3855749..47d86e1 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 @@ -19,8 +19,8 @@ import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.XWorkException; import com.opensymphony.xwork2.util.location.Location; import com.opensymphony.xwork2.util.location.LocationAttributes; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -92,7 +92,7 @@ public class DomHelper { factory.setValidating((dtdMappings != null)); factory.setNamespaceAware(true); - SAXParser parser = null; + SAXParser parser; try { parser = factory.newSAXParser(); } catch (Exception ex) { @@ -344,8 +344,7 @@ public class DomHelper { @Override public void error(SAXParseException exception) throws SAXException { - LOG.error(exception.getMessage() + " at (" + exception.getPublicId() + ":" + - exception.getLineNumber() + ":" + exception.getColumnNumber() + ")", exception); + LOG.error("{} at ({}:{}:{})", exception.getMessage(), exception.getPublicId(), exception.getLineNumber(), exception.getColumnNumber(), exception); throw exception; } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/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 1a46ecf..2d9afa2 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 @@ -25,10 +25,10 @@ import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.ModelDriven; import com.opensymphony.xwork2.conversion.impl.XWorkConverter; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; import com.opensymphony.xwork2.util.reflection.ReflectionProviderFactory; import org.apache.commons.lang3.ObjectUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.beans.PropertyDescriptor; import java.lang.reflect.Field; @@ -90,14 +90,14 @@ public class LocalizedTextUtil { private static final String TOMCAT_RESOURCE_ENTRIES_FIELD = "resourceEntries"; - private static final ConcurrentMap<Integer, List<String>> classLoaderMap = new ConcurrentHashMap<Integer, List<String>>(); + private static final ConcurrentMap<Integer, List<String>> classLoaderMap = new ConcurrentHashMap<>(); private static boolean reloadBundles = false; private static boolean devMode; - private static final ConcurrentMap<String, ResourceBundle> bundlesMap = new ConcurrentHashMap<String, ResourceBundle>(); - private static final ConcurrentMap<MessageFormatKey, MessageFormat> messageFormats = new ConcurrentHashMap<MessageFormatKey, MessageFormat>(); - private static final ConcurrentMap<Integer, ClassLoader> delegatedClassLoaderMap = new ConcurrentHashMap<Integer, ClassLoader>(); + private static final ConcurrentMap<String, ResourceBundle> bundlesMap = new ConcurrentHashMap<>(); + private static final ConcurrentMap<MessageFormatKey, MessageFormat> messageFormats = new ConcurrentHashMap<>(); + private static final ConcurrentMap<Integer, ClassLoader> delegatedClassLoaderMap = new ConcurrentHashMap<>(); private static final String RELOADED = "com.opensymphony.xwork2.util.LocalizedTextUtil.reloaded"; private static final String XWORK_MESSAGES_BUNDLE = "com/opensymphony/xwork2/xwork-messages"; @@ -112,7 +112,7 @@ public class LocalizedTextUtil { */ public static void clearDefaultResourceBundles() { ClassLoader ccl = getCurrentThreadContextClassLoader(); - List<String> bundles = new ArrayList<String>(); + List<String> bundles = new ArrayList<>(); classLoaderMap.put(ccl.hashCode(), bundles); bundles.add(0, XWORK_MESSAGES_BUNDLE); } @@ -417,9 +417,7 @@ public class LocalizedTextUtil { ValueStack valueStack) { String indexedTextName = null; if (aTextName == null) { - if (LOG.isWarnEnabled()) { LOG.warn("Trying to find text with null key!"); - } aTextName = ""; } // calculate indexedTextName (collection[*]) if applicable @@ -518,12 +516,13 @@ public class LocalizedTextUtil { Class clazz = propertyDescriptor.getPropertyType(); if (clazz != null) { - if (obj != null) + if (obj != null) { valueStack.push(obj); + } msg = findText(clazz, newKey, locale, null, args); - if (obj != null) + if (obj != null) { valueStack.pop(); - + } if (msg != null) { return msg; } @@ -531,7 +530,7 @@ public class LocalizedTextUtil { } } } catch (Exception e) { - LOG.debug("unable to find property " + prop, e); + LOG.debug("unable to find property {}", prop, e); } } } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcher.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcher.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcher.java index 1203a49..8d197c6 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcher.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcher.java @@ -74,7 +74,7 @@ public class NamedVariablePatternMatcher implements PatternMatcher<NamedVariable public CompiledPattern compilePattern(String data) { StringBuilder regex = new StringBuilder(); if (data != null && data.length() > 0) { - List<String> varNames = new ArrayList<String>(); + List<String> varNames = new ArrayList<>(); StringBuilder varName = null; for (int x=0; x<data.length(); x++) { char c = data.charAt(x); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/PropertiesReader.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/PropertiesReader.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/PropertiesReader.java index 5a086c9..a25a679 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/PropertiesReader.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/PropertiesReader.java @@ -25,37 +25,54 @@ import java.util.List; * not terminate with new-line chars but rather when there is no * backslash sign a the end of the line. This is used to * concatenate multiple lines for readability. - * + * <p/> * This class was pulled out of Jakarta Commons Configuration and * Jakarta Commons Lang trunk revision 476093 */ -public class PropertiesReader extends LineNumberReader -{ - /** Stores the comment lines for the currently processed property.*/ +public class PropertiesReader extends LineNumberReader { + /** + * Stores the comment lines for the currently processed property. + */ private List<String> commentLines; - /** Stores the name of the last read property.*/ + /** + * Stores the name of the last read property. + */ private String propertyName; - /** Stores the value of the last read property.*/ + /** + * Stores the value of the last read property. + */ private String propertyValue; - /** Stores the list delimiter character.*/ + /** + * Stores the list delimiter character. + */ private char delimiter; - - /** Constant for the supported comment characters.*/ + + /** + * Constant for the supported comment characters. + */ static final String COMMENT_CHARS = "#!"; - - /** Constant for the radix of hex numbers.*/ + + /** + * Constant for the radix of hex numbers. + */ private static final int HEX_RADIX = 16; - /** Constant for the length of a unicode literal.*/ + /** + * Constant for the length of a unicode literal. + */ private static final int UNICODE_LEN = 4; - - /** The list of possible key/value separators */ - private static final char[] SEPARATORS = new char[] {'=', ':'}; - /** The white space characters used as key/value separators. */ + /** + * The list of possible key/value separators + */ + private static final char[] SEPARATORS = new char[]{'=', ':'}; + + /** + * The white space characters used as key/value separators. + */ private static final char[] WHITE_SPACE = new char[]{' ', '\t', '\f'}; /** @@ -63,8 +80,7 @@ public class PropertiesReader extends LineNumberReader * * @param reader A Reader. */ - public PropertiesReader(Reader reader) - { + public PropertiesReader(Reader reader) { this(reader, ','); } @@ -72,17 +88,16 @@ public class PropertiesReader extends LineNumberReader * Creates a new instance of <code>PropertiesReader</code> and sets * the underlaying reader and the list delimiter. * - * @param reader the reader + * @param reader the reader * @param listDelimiter the list delimiter character * @since 1.3 */ - public PropertiesReader(Reader reader, char listDelimiter) - { + public PropertiesReader(Reader reader, char listDelimiter) { super(reader); commentLines = new ArrayList<String>(); delimiter = listDelimiter; } - + /** * Tests whether a line is a comment, i.e. whether it starts with a comment * character. @@ -91,8 +106,7 @@ public class PropertiesReader extends LineNumberReader * @return a flag if this is a comment line * @since 1.3 */ - boolean isCommentLine(String line) - { + boolean isCommentLine(String line) { String s = line.trim(); // blanc lines are also treated as comment lines return s.length() < 1 || COMMENT_CHARS.indexOf(s.charAt(0)) >= 0; @@ -106,38 +120,30 @@ public class PropertiesReader extends LineNumberReader * = <code><value></code>) * * @return A string containing a property value or null - * * @throws IOException in case of an I/O error */ - public String readProperty() throws IOException - { + public String readProperty() throws IOException { commentLines.clear(); StringBuilder buffer = new StringBuilder(); - while (true) - { + while (true) { String line = readLine(); - if (line == null) - { + if (line == null) { // EOF return null; } - if (isCommentLine(line)) - { + if (isCommentLine(line)) { commentLines.add(line); continue; } line = line.trim(); - if (checkCombineLines(line)) - { + if (checkCombineLines(line)) { line = line.substring(0, line.length() - 1); buffer.append(line); - } - else - { + } else { buffer.append(line); break; } @@ -156,12 +162,10 @@ public class PropertiesReader extends LineNumberReader * @throws IOException if an error occurs * @since 1.3 */ - public boolean nextProperty() throws IOException - { + public boolean nextProperty() throws IOException { String line = readProperty(); - if (line == null) - { + if (line == null) { return false; // EOF } @@ -179,8 +183,7 @@ public class PropertiesReader extends LineNumberReader * <code>readProperty()</code> * @since 1.3 */ - public List<String> getCommentLines() - { + public List<String> getCommentLines() { return commentLines; } @@ -192,8 +195,7 @@ public class PropertiesReader extends LineNumberReader * @return the name of the last read property * @since 1.3 */ - public String getPropertyName() - { + public String getPropertyName() { return propertyName; } @@ -205,8 +207,7 @@ public class PropertiesReader extends LineNumberReader * @return the value of the last read property * @since 1.3 */ - public String getPropertyValue() - { + public String getPropertyValue() { return propertyValue; } @@ -217,11 +218,9 @@ public class PropertiesReader extends LineNumberReader * @param line the line * @return a flag if the lines should be combined */ - private boolean checkCombineLines(String line) - { + private boolean checkCombineLines(String line) { int bsCount = 0; - for (int idx = line.length() - 1; idx >= 0 && line.charAt(idx) == '\\'; idx--) - { + for (int idx = line.length() - 1; idx >= 0 && line.charAt(idx) == '\\'; idx--) { bsCount++; } @@ -235,8 +234,7 @@ public class PropertiesReader extends LineNumberReader * @return an array with the property's key and value * @since 1.2 */ - private String[] parseProperty(String line) - { + private String[] parseProperty(String line) { // sorry for this spaghetti code, please replace it as soon as // possible with a regexp when the Java 1.3 requirement is dropped @@ -251,42 +249,30 @@ public class PropertiesReader extends LineNumberReader // 3: value parsing int state = 0; - for (int pos = 0; pos < line.length(); pos++) - { + for (int pos = 0; pos < line.length(); pos++) { char c = line.charAt(pos); - switch (state) - { + switch (state) { case 0: - if (c == '\\') - { + if (c == '\\') { state = 1; - } - else if (contains(WHITE_SPACE, c)) - { + } else if (contains(WHITE_SPACE, c)) { // switch to the separator crossing state state = 2; - } - else if (contains(SEPARATORS, c)) - { + } else if (contains(SEPARATORS, c)) { // switch to the value parsing state state = 3; - } - else - { + } else { key.append(c); } break; case 1: - if (contains(SEPARATORS, c) || contains(WHITE_SPACE, c)) - { + if (contains(SEPARATORS, c) || contains(WHITE_SPACE, c)) { // this is an escaped separator or white space key.append(c); - } - else - { + } else { // another escaped character, the '\' is preserved key.append('\\'); key.append(c); @@ -298,18 +284,13 @@ public class PropertiesReader extends LineNumberReader break; case 2: - if (contains(WHITE_SPACE, c)) - { + if (contains(WHITE_SPACE, c)) { // do nothing, eat all white spaces state = 2; - } - else if (contains(SEPARATORS, c)) - { + } else if (contains(SEPARATORS, c)) { // switch to the value parsing state state = 3; - } - else - { + } else { // any other character indicates we encoutered the beginning of the value value.append(c); @@ -330,22 +311,20 @@ public class PropertiesReader extends LineNumberReader return result; } - + /** * <p>Unescapes any Java literals found in the <code>String</code> to a * <code>Writer</code>.</p> This is a slightly modified version of the * StringEscapeUtils.unescapeJava() function in commons-lang that doesn't * drop escaped separators (i.e '\,'). * - * @param str the <code>String</code> to unescape, may be null + * @param str the <code>String</code> to unescape, may be null * @param delimiter the delimiter for multi-valued properties * @return the processed string * @throws IllegalArgumentException if the Writer is <code>null</code> */ - protected static String unescapeJava(String str, char delimiter) - { - if (str == null) - { + protected static String unescapeJava(String str, char delimiter) { + if (str == null) { return null; } int sz = str.length(); @@ -353,98 +332,67 @@ public class PropertiesReader extends LineNumberReader StringBuffer unicode = new StringBuffer(UNICODE_LEN); boolean hadSlash = false; boolean inUnicode = false; - for (int i = 0; i < sz; i++) - { + for (int i = 0; i < sz; i++) { char ch = str.charAt(i); - if (inUnicode) - { + if (inUnicode) { // if in unicode, then we're reading unicode // values in somehow unicode.append(ch); - if (unicode.length() == UNICODE_LEN) - { + if (unicode.length() == UNICODE_LEN) { // unicode now contains the four hex digits // which represents our unicode character - try - { + try { int value = Integer.parseInt(unicode.toString(), HEX_RADIX); out.append((char) value); unicode.setLength(0); inUnicode = false; hadSlash = false; - } - catch (NumberFormatException nfe) - { + } catch (NumberFormatException nfe) { throw new RuntimeException("Unable to parse unicode value: " + unicode, nfe); } } continue; } - if (hadSlash) - { + if (hadSlash) { // handle an escaped value hadSlash = false; - if (ch == '\\') - { + if (ch == '\\') { out.append('\\'); - } - else if (ch == '\'') - { + } else if (ch == '\'') { out.append('\''); - } - else if (ch == '\"') - { + } else if (ch == '\"') { out.append('"'); - } - else if (ch == 'r') - { + } else if (ch == 'r') { out.append('\r'); - } - else if (ch == 'f') - { + } else if (ch == 'f') { out.append('\f'); - } - else if (ch == 't') - { + } else if (ch == 't') { out.append('\t'); - } - else if (ch == 'n') - { + } else if (ch == 'n') { out.append('\n'); - } - else if (ch == 'b') - { + } else if (ch == 'b') { out.append('\b'); - } - else if (ch == delimiter) - { + } else if (ch == delimiter) { out.append('\\'); out.append(delimiter); - } - else if (ch == 'u') - { + } else if (ch == 'u') { // uh-oh, we're in unicode country.... inUnicode = true; - } - else - { + } else { out.append(ch); } continue; - } - else if (ch == '\\') - { + } else if (ch == '\\') { hadSlash = true; continue; } out.append(ch); } - if (hadSlash) - { + if (hadSlash) { // then we're in the weird case of a \ at the end of the // string, let's output it anyway. out.append('\\'); @@ -452,14 +400,14 @@ public class PropertiesReader extends LineNumberReader return out.toString(); } - + /** * <p>Checks if the object is in the given array.</p> - * + * <p/> * <p>The method returns <code>false</code> if a <code>null</code> array is passed in.</p> - * - * @param array the array to search through - * @param objectToFind the object to find + * + * @param array the array to search through + * @param objectToFind the object to find * @return <code>true</code> if the array contains the object */ public boolean contains(char[] array, char objectToFind) { @@ -473,14 +421,14 @@ public class PropertiesReader extends LineNumberReader } return false; } - + /** * <p>Unescapes any Java literals found in the <code>String</code>. * For example, it will turn a sequence of <code>'\'</code> and * <code>'n'</code> into a newline character, unless the <code>'\'</code> * is preceded by another <code>'\'</code>.</p> - * - * @param str the <code>String</code> to unescape, may be null + * + * @param str the <code>String</code> to unescape, may be null * @return a new unescaped <code>String</code>, <code>null</code> if null string input */ public static String unescapeJava(String str) { @@ -501,17 +449,17 @@ public class PropertiesReader extends LineNumberReader /** * <p>Unescapes any Java literals found in the <code>String</code> to a * <code>Writer</code>.</p> - * + * <p/> * <p>For example, it will turn a sequence of <code>'\'</code> and * <code>'n'</code> into a newline character, unless the <code>'\'</code> * is preceded by another <code>'\'</code>.</p> - * + * <p/> * <p>A <code>null</code> string input has no effect.</p> - * - * @param out the <code>Writer</code> used to output unescaped characters - * @param str the <code>String</code> to unescape, may be null + * + * @param out the <code>Writer</code> used to output unescaped characters + * @param str the <code>String</code> to unescape, may be null * @throws IllegalArgumentException if the Writer is <code>null</code> - * @throws IOException if error occurs on underlying Writer + * @throws IOException if error occurs on underlying Writer */ public static void unescapeJava(Writer out, String str) throws IOException { if (out == null) { @@ -573,13 +521,12 @@ public class PropertiesReader extends LineNumberReader case 'b': out.write('\b'); break; - case 'u': - { - // uh-oh, we're in unicode country.... - inUnicode = true; - break; - } - default : + case 'u': { + // uh-oh, we're in unicode country.... + inUnicode = true; + break; + } + default: out.write(ch); break; } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/TextParseUtil.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/TextParseUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/TextParseUtil.java index 211d08c..db1af6d 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/TextParseUtil.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/TextParseUtil.java @@ -19,11 +19,7 @@ import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.conversion.impl.XWorkConverter; import com.opensymphony.xwork2.inject.Container; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; /** @@ -119,7 +115,7 @@ public class TextParseUtil { /** * Converted object from variable translation. * - * @param open + * @param openChars * @param expression * @param stack * @param asType @@ -147,7 +143,7 @@ public class TextParseUtil { /** * Converted object from variable translation. * - * @param open + * @param openChars * @param expression * @param stack * @param asType @@ -216,7 +212,7 @@ public class TextParseUtil { if (result instanceof Collection) { @SuppressWarnings("unchecked") Collection<Object> casted = (Collection<Object>)result; - resultCol = new ArrayList<String>(); + resultCol = new ArrayList<>(); XWorkConverter conv = ((Container)context.get(ActionContext.CONTAINER)).getInstance(XWorkConverter.class); @@ -230,7 +226,7 @@ public class TextParseUtil { } } } else { - resultCol = new ArrayList<String>(); + resultCol = new ArrayList<>(); String resultStr = translateVariables(expression, stack, evaluator); if (shallBeIncluded(resultStr, excludeEmptyElements)) { resultCol.add(resultStr); @@ -258,7 +254,7 @@ public class TextParseUtil { * @return A set from comma delimted Strings. */ public static Set<String> commaDelimitedStringToSet(String s) { - Set<String> set = new HashSet<String>(); + Set<String> set = new HashSet<>(); String[] split = s.split(","); for (String aSplit : split) { String trimmed = aSplit.trim(); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/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 58ce870..006fd5e 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 @@ -15,10 +15,12 @@ */ package com.opensymphony.xwork2.util; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; /** @@ -46,10 +48,14 @@ public class URLUtil { } try { - new URL(url); - + URL u = new URL(url); + URI uri = u.toURI(); // perform a additional url syntax check + if (uri.getHost() == null) { + LOG.debug("Url [{}] does not contains a valid host: {}", url, uri); + return false; + } return true; - } catch (MalformedURLException e) { + } catch (MalformedURLException | URISyntaxException e) { LOG.debug("Url [{}] is invalid: {}", url, e.getMessage(), e); return false; } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/XWorkList.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/XWorkList.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/XWorkList.java index d627473..2a50197 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/XWorkList.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/XWorkList.java @@ -20,8 +20,8 @@ import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.XWorkException; import com.opensymphony.xwork2.conversion.TypeConverter; import com.opensymphony.xwork2.conversion.impl.XWorkConverter; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.ArrayList; import java.util.Collection; @@ -98,18 +98,18 @@ public class XWorkList extends ArrayList { * <p/> * This method performs any necessary type conversion. * - * @param c the elements to be inserted into this list. + * @param collection the elements to be inserted into this list. * @return <tt>true</tt> if this list changed as a result of the call. * @throws NullPointerException if the specified collection is null. */ @Override - public boolean addAll(Collection c) { - if (c == null) { + public boolean addAll(Collection collection) { + if (collection == null) { throw new NullPointerException("Collection to add is null"); } - for (Object aC : c) { - add(aC); + for (Object nextElement : collection) { + add(nextElement); } return true; @@ -126,12 +126,12 @@ public class XWorkList extends ArrayList { * also performs any necessary type conversion. * * @param index index at which to insert first element from the specified collection. - * @param c elements to be inserted into this list. + * @param collection elements to be inserted into this list. * @return <tt>true</tt> if this list changed as a result of the call. */ @Override - public boolean addAll(int index, Collection c) { - if (c == null) { + public boolean addAll(int index, Collection collection) { + if (collection == null) { throw new NullPointerException("Collection to add is null"); } @@ -141,7 +141,7 @@ public class XWorkList extends ArrayList { trim = true; } - for (Iterator it = c.iterator(); it.hasNext(); index++) { + for (Iterator it = collection.iterator(); it.hasNext(); index++) { add(index, it.next()); } @@ -203,12 +203,10 @@ public class XWorkList extends ArrayList { private Object convert(Object element) { if ((element != null) && !clazz.isAssignableFrom(element.getClass())) { // convert to correct type - if (LOG.isDebugEnabled()) { - LOG.debug("Converting from " + element.getClass().getName() + " to " + clazz.getName()); - } - TypeConverter conv = getTypeConverter(); + LOG.debug("Converting from {} to {}", element.getClass().getName(), clazz.getName()); + TypeConverter converter = getTypeConverter(); Map<String, Object> context = ActionContext.getContext().getContextMap(); - element = conv.convertValue(context, null, null, null, element, clazz); + element = converter.convertValue(context, null, null, null, element, clazz); } return element; @@ -221,7 +219,6 @@ public class XWorkList extends ArrayList { @Override public boolean contains(Object element) { element = convert(element); - return super.contains(element); } } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/XWorkTestCaseHelper.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/XWorkTestCaseHelper.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/XWorkTestCaseHelper.java index f5f70ed..d81b84e 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/XWorkTestCaseHelper.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/XWorkTestCaseHelper.java @@ -60,8 +60,7 @@ public class XWorkTestCaseHelper { public void init(Configuration configuration) throws ConfigurationException {} public boolean needsReload() { return false; } - public void register(ContainerBuilder builder, - LocatableProperties props) throws ConfigurationException { + public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { builder.setAllowDuplicates(true); } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/AbstractResourceStore.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/AbstractResourceStore.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/AbstractResourceStore.java new file mode 100644 index 0000000..9166389 --- /dev/null +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/AbstractResourceStore.java @@ -0,0 +1,50 @@ +/* + * Copyright 2002-2015 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.opensymphony.xwork2.util.classloader; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + + +public abstract class AbstractResourceStore implements ResourceStore { + private static final Logger log = LogManager.getLogger(JarResourceStore.class); + protected final File file; + + public AbstractResourceStore(final File file) { + this.file = file; + } + + protected void closeQuietly(InputStream is) { + try { + if (is != null) { + is.close(); + } + } catch (IOException e) { + log.error("Unable to close file input stream", e); + } + } + + public void write(String pResourceName, byte[] pResourceData) { + } + + public String toString() { + return this.getClass().getName() + file.toString(); + } +} http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/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 3b2714e..c2c79ea 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 @@ -15,25 +15,22 @@ */ package com.opensymphony.xwork2.util.classloader; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; /** * Reads a class from disk * class taken from Apache JCI */ -public final class FileResourceStore implements ResourceStore { +public final class FileResourceStore extends AbstractResourceStore { private static final Logger LOG = LogManager.getLogger(FileResourceStore.class); - private final File root; - public FileResourceStore(final File pFile) { - root = pFile; + public FileResourceStore(final File file) { + super(file); } public byte[] read(final String pResourceName) { @@ -53,25 +50,8 @@ public final class FileResourceStore implements ResourceStore { } } - public void write(final String pResourceName, final byte[] pData) { - - } - - private void closeQuietly(InputStream is) { - try { - if (is != null) - is.close(); - } catch (IOException e) { - LOG.error("Unable to close file input stream", e); - } - } - private File getFile(final String pResourceName) { final String fileName = pResourceName.replace('/', File.separatorChar); - return new File(root, fileName); - } - - public String toString() { - return this.getClass().getName() + root.toString(); + return new File(file, fileName); } } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/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 f7528b0..c5c1cc7 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 @@ -16,8 +16,8 @@ package com.opensymphony.xwork2.util.classloader; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.*; import java.util.zip.ZipEntry; @@ -26,16 +26,11 @@ import java.util.zip.ZipFile; /** * Read resources from a jar file */ -public class JarResourceStore implements ResourceStore { +public class JarResourceStore extends AbstractResourceStore { private static final Logger LOG = LogManager.getLogger(JarResourceStore.class); - private final File file; - public JarResourceStore(File file) { - this.file = file; - } - - public void write(String pResourceName, byte[] pResourceData) { + super(file); } public byte[] read(String pResourceName) { @@ -58,8 +53,7 @@ public class JarResourceStore implements ResourceStore { } } - public static long copy(InputStream input, OutputStream output) - throws IOException { + public static long copy(InputStream input, OutputStream output) throws IOException { byte[] buffer = new byte[1024 * 4]; long count = 0; int n = 0; @@ -69,13 +63,4 @@ public class JarResourceStore implements ResourceStore { } return count; } - - private void closeQuietly(InputStream is) { - try { - if (is != null) - is.close(); - } catch (IOException e) { - LOG.error("Unable to close input stream", e); - } - } } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/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 3d17ca4..55fe34f 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 @@ -19,9 +19,9 @@ import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.FileManager; import com.opensymphony.xwork2.FileManagerFactory; import com.opensymphony.xwork2.XWorkException; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; import org.apache.commons.lang3.ObjectUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.InputStream; @@ -125,8 +125,7 @@ public class ReloadingClassLoader extends ClassLoader { } public void reload() { - if (LOG.isTraceEnabled()) - LOG.trace("Reloading class loader"); + LOG.trace("Reloading class loader"); delegate = new ResourceStoreClassLoader(parent, stores); } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/ResourceStoreClassLoader.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/ResourceStoreClassLoader.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/ResourceStoreClassLoader.java index d84c106..8d4a688 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/ResourceStoreClassLoader.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/classloader/ResourceStoreClassLoader.java @@ -15,16 +15,11 @@ */ package com.opensymphony.xwork2.util.classloader; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - /** * class taken from Apache JCI */ public final class ResourceStoreClassLoader extends ClassLoader { - private static final Logger LOG = LogManager.getLogger(ResourceStoreClassLoader.class); - private final ResourceStore[] stores; public ResourceStoreClassLoader(final ClassLoader pParent, final ResourceStore[] pStores) { @@ -63,7 +58,6 @@ public final class ResourceStoreClassLoader extends ClassLoader { } else { throw new ClassNotFoundException(name); } - } } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ClassFinder.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ClassFinder.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ClassFinder.java index cf8fb9b..50fde4a 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ClassFinder.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ClassFinder.java @@ -90,7 +90,7 @@ public interface ClassFinder { } public class Annotatable { - private final List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>(); + private final List<AnnotationInfo> annotations = new ArrayList<>(); public Annotatable(AnnotatedElement element) { for (Annotation annotation : element.getAnnotations()) { @@ -136,12 +136,12 @@ public interface ClassFinder { public class ClassInfo extends Annotatable implements Info { private final String name; - private final List<MethodInfo> methods = new ArrayList<MethodInfo>(); - private final List<MethodInfo> constructors = new ArrayList<MethodInfo>(); + private final List<MethodInfo> methods = new ArrayList<>(); + private final List<MethodInfo> constructors = new ArrayList<>(); private final String superType; - private final List<String> interfaces = new ArrayList<String>(); - private final List<String> superInterfaces = new ArrayList<String>(); - private final List<FieldInfo> fields = new ArrayList<FieldInfo>(); + private final List<String> interfaces = new ArrayList<>(); + private final List<String> superInterfaces = new ArrayList<>(); + private final List<FieldInfo> fields = new ArrayList<>(); private Class<?> clazz; private ClassFinder classFinder; private ClassNotFoundException notFound; @@ -216,7 +216,7 @@ public interface ClassFinder { private final ClassInfo declaringClass; private final String returnType; private final String name; - private final List<List<AnnotationInfo>> parameterAnnotations = new ArrayList<List<AnnotationInfo>>(); + private final List<List<AnnotationInfo>> parameterAnnotations = new ArrayList<>(); public MethodInfo(ClassInfo info, Constructor constructor){ super(constructor); @@ -245,7 +245,7 @@ public interface ClassFinder { public List<AnnotationInfo> getParameterAnnotations(int index) { if (index >= parameterAnnotations.size()) { for (int i = parameterAnnotations.size(); i <= index; i++) { - List<AnnotationInfo> annotationInfos = new ArrayList<AnnotationInfo>(); + List<AnnotationInfo> annotationInfos = new ArrayList<>(); parameterAnnotations.add(i, annotationInfos); } }
