diff --git a/buildSrc/src/main/groovy/org/springframework/build/gradle/MergePlugin.groovy b/buildSrc/src/main/groovy/org/springframework/build/gradle/MergePlugin.groovy index 426b5aabfe8..fbf683fe818 100644 --- a/buildSrc/src/main/groovy/org/springframework/build/gradle/MergePlugin.groovy +++ b/buildSrc/src/main/groovy/org/springframework/build/gradle/MergePlugin.groovy @@ -21,13 +21,10 @@ import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.ProjectDependency; import org.gradle.api.artifacts.maven.Conf2ScopeMapping import org.gradle.api.plugins.MavenPlugin -import org.gradle.api.tasks.* import org.gradle.plugins.ide.eclipse.EclipsePlugin -import org.gradle.plugins.ide.eclipse.model.EclipseClasspath; import org.gradle.plugins.ide.idea.IdeaPlugin import org.gradle.api.invocation.* - /** * Gradle plugin that allows projects to merged together. Primarily developed to * allow Spring to support multiple incompatible versions of third-party @@ -76,13 +73,13 @@ class MergePlugin implements Plugin { // Hook to perform the actual merge logic project.afterEvaluate{ - if(it.merge.into != null) { + if (it.merge.into != null) { setup(it) } } // Hook to build runtimeMerge dependencies - if(!attachedProjectsEvaluated) { + if (!attachedProjectsEvaluated) { project.gradle.projectsEvaluated{ postProcessProjects(it) } @@ -102,7 +99,7 @@ class MergePlugin implements Plugin { // invoking a task will invoke the task with the same name on 'into' project ["sourcesJar", "jar", "javadocJar", "javadoc", "install", "artifactoryPublish"].each { def task = project.tasks.findByPath(it) - if(task) { + if (task) { task.enabled = false task.dependsOn(project.merge.into.tasks.findByPath(it)) } @@ -120,7 +117,7 @@ class MergePlugin implements Plugin { private void setupMaven(Project project) { project.configurations.each { configuration -> Conf2ScopeMapping mapping = project.conf2ScopeMappings.getMapping([configuration]) - if(mapping.scope) { + if (mapping.scope) { Configuration intoConfiguration = project.merge.into.configurations.create( project.name + "-" + configuration.name) configuration.excludeRules.each { @@ -131,7 +128,7 @@ class MergePlugin implements Plugin { configuration.dependencies.each { def intoCompile = project.merge.into.configurations.getByName("compile") // Protect against changing a compile scope dependency (SPR-10218) - if(!intoCompile.dependencies.contains(it)) { + if (!intoCompile.dependencies.contains(it)) { intoConfiguration.dependencies.add(it) } } diff --git a/buildSrc/src/main/groovy/org/springframework/build/gradle/TestSourceSetDependenciesPlugin.groovy b/buildSrc/src/main/groovy/org/springframework/build/gradle/TestSourceSetDependenciesPlugin.groovy index 1d6134ab597..8d252ffb790 100644 --- a/buildSrc/src/main/groovy/org/springframework/build/gradle/TestSourceSetDependenciesPlugin.groovy +++ b/buildSrc/src/main/groovy/org/springframework/build/gradle/TestSourceSetDependenciesPlugin.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ import org.gradle.api.Project import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.ProjectDependency; - /** * Gradle plugin that automatically updates testCompile dependencies to include * the test source sets of project dependencies. @@ -43,9 +42,9 @@ class TestSourceSetDependenciesPlugin implements Plugin { private void collectProjectDependencies(Set projectDependencies, Project project) { - for(def configurationName in ["compile", "optional", "provided", "testCompile"]) { + for (def configurationName in ["compile", "optional", "provided", "testCompile"]) { Configuration configuration = project.getConfigurations().findByName(configurationName) - if(configuration) { + if (configuration) { configuration.dependencies.findAll { it instanceof ProjectDependency }.each { projectDependencies.add(it) collectProjectDependencies(projectDependencies, it.dependencyProject) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java b/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java index 68a621419f2..e93aa9e5cbe 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java @@ -215,8 +215,10 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa // is type-compatible. Note that we can't help if the target sets // a reference to itself in another returned object. retVal = proxy; - } else if (retVal == null && returnType != Void.TYPE && returnType.isPrimitive()) { - throw new AopInvocationException("Null return value from advice does not match primitive return type for: " + method); + } + else if (retVal == null && returnType != Void.TYPE && returnType.isPrimitive()) { + throw new AopInvocationException( + "Null return value from advice does not match primitive return type for: " + method); } return retVal; } diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java index 5801d40550b..f8b19cb71fc 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java @@ -258,7 +258,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { return returnValue; } catch (Throwable ex) { - if(stopWatch.isRunning()) { + if (stopWatch.isRunning()) { stopWatch.stop(); } exitThroughException = true; @@ -268,7 +268,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { } finally { if (!exitThroughException) { - if(stopWatch.isRunning()) { + if (stopWatch.isRunning()) { stopWatch.stop(); } writeToLog(logger, diff --git a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractDependencyInjectionAspect.aj b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractDependencyInjectionAspect.aj index fa8fc6441f3..58bebb9176f 100644 --- a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractDependencyInjectionAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractDependencyInjectionAspect.aj @@ -46,7 +46,7 @@ public abstract aspect AbstractDependencyInjectionAspect { * Select join points in beans to be configured prior to construction? * By default, use post-construction injection matching the default in the Configurable annotation. */ - public pointcut preConstructionConfiguration() : if(false); + public pointcut preConstructionConfiguration() : if (false); /** * Select the most-specific initialization join point @@ -54,7 +54,7 @@ public abstract aspect AbstractDependencyInjectionAspect { */ @CodeGenerationHint(ifNameSuffix="6f1") public pointcut mostSpecificSubTypeConstruction() : - if(thisJoinPoint.getSignature().getDeclaringType() == thisJoinPoint.getThis().getClass()); + if (thisJoinPoint.getSignature().getDeclaringType() == thisJoinPoint.getThis().getClass()); /** * Select least specific super type that is marked for DI (so that injection occurs only once with pre-construction inejection diff --git a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AnnotationBeanConfigurerAspect.aj b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AnnotationBeanConfigurerAspect.aj index 2f1e91ccd23..eea0835bd08 100644 --- a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AnnotationBeanConfigurerAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AnnotationBeanConfigurerAspect.aj @@ -79,7 +79,7 @@ public aspect AnnotationBeanConfigurerAspect * An intermediary to match preConstructionConfiguration signature (that doesn't expose the annotation object) */ @CodeGenerationHint(ifNameSuffix="bb0") - private pointcut preConstructionConfigurationSupport(Configurable c) : @this(c) && if(c.preConstruction()); + private pointcut preConstructionConfigurationSupport(Configurable c) : @this(c) && if (c.preConstruction()); /* * This declaration shouldn't be needed, diff --git a/spring-aspects/src/main/java/org/springframework/cache/aspectj/JCacheCacheAspect.aj b/spring-aspects/src/main/java/org/springframework/cache/aspectj/JCacheCacheAspect.aj index 3bb86d54534..f6577303fbe 100644 --- a/spring-aspects/src/main/java/org/springframework/cache/aspectj/JCacheCacheAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/cache/aspectj/JCacheCacheAspect.aj @@ -55,7 +55,8 @@ public aspect JCacheCacheAspect extends JCacheAspectSupport { public Object invoke() { try { return proceed(cachedObject); - } catch (Throwable ex) { + } + catch (Throwable ex) { throw new ThrowableWrapper(ex); } } @@ -120,4 +121,4 @@ public aspect JCacheCacheAspect extends JCacheAspectSupport { } } -} \ No newline at end of file +} diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java index e43c9013e55..056b88b587a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java @@ -378,7 +378,8 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra if (pd.getReadMethod() != null || pd.getWriteMethod() != null) { return TypeDescriptor.nested(property(pd), tokens.keys.length); } - } else { + } + else { if (pd.getReadMethod() != null || pd.getWriteMethod() != null) { return new TypeDescriptor(property(pd)); } diff --git a/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java b/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java index 3a5ea914fef..c9d188cdf33 100644 --- a/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java @@ -34,7 +34,7 @@ import org.springframework.util.ReflectionUtils; * {@link PropertyAccessor} implementation that directly accesses instance fields. * Allows for direct binding to fields instead of going through JavaBean setters. * - *

Since 4.1 this implementation supports nested fields traversing. + *

As of Spring 4.1, this implementation supports nested field traversal. * *

A DirectFieldAccessor's default for the "extractOldValueForEditor" setting * is "true", since a field can always be read without side effects. @@ -188,7 +188,6 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor { /** * Create a root {@link FieldAccessor}. - * * @param canonicalName the full expression for the field to access * @param actualName the name of the local (root) property * @param field the field accessing the property @@ -212,13 +211,13 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor { private final Field field; /** - * Create a new instance. + * Create a new FieldAccessor instance. * @param parent the parent accessor, if any * @param canonicalName the full expression for the field to access * @param actualName the name of the partial expression for this property * @param field the field accessing the property */ - private FieldAccessor(FieldAccessor parent, String canonicalName, String actualName, Field field) { + public FieldAccessor(FieldAccessor parent, String canonicalName, String actualName, Field field) { Assert.notNull(canonicalName, "Expression must no be null"); Assert.notNull(field, "Field must no be null"); this.parents = buildParents(parent); @@ -229,7 +228,6 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor { /** * Create a child instance. - * * @param actualName the name of the child property * @param field the field accessing the child property */ @@ -238,7 +236,7 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor { } public Field getField() { - return field; + return this.field; } public Object getValue() { @@ -252,9 +250,8 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor { try { this.field.set(localTarget, value); } - catch (IllegalAccessException e) { - throw new InvalidPropertyException(localTarget.getClass(), canonicalName, - "Field is not accessible", e); + catch (IllegalAccessException ex) { + throw new InvalidPropertyException(localTarget.getClass(), canonicalName, "Field is not accessible", ex); } } @@ -275,8 +272,8 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor { localTarget = autoGrowIfNecessary(parent, parent.getParentValue(localTarget)); if (localTarget == null) { // Could not traverse the graph any further throw new NullValueInNestedPathException(getRootClass(), parent.actualName, - "Cannot access indexed value of property referenced in indexed " + - "property path '" + getField().getName() + "': returned null"); + "Cannot access indexed value of property referenced in indexed property path '" + + getField().getName() + "': returned null"); } } return localTarget; @@ -287,10 +284,10 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor { try { return type.newInstance(); } - catch (Exception e) { + catch (Exception ex) { throw new NullValueInNestedPathException(getRootClass(), this.actualName, - "Could not instantiate property type [" + type.getName() + "] to " + - "auto-grow nested property path: " + e); + "Could not instantiate property type [" + type.getName() + + "] to auto-grow nested property path: " + ex); } } @@ -311,7 +308,6 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor { } return parents; } - } } diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java b/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java index e69b09b71a0..ea860ec1610 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -172,7 +172,8 @@ final class PropertyMatches { char t_j = s2.charAt(j - 1); if (s_i == t_j) { cost = 0; - } else { + } + else { cost = 1; } d[i][j] = Math.min(Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1), diff --git a/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java b/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java index d34d8011b5c..513393bd7cc 100644 --- a/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java @@ -316,12 +316,12 @@ class TypeConverterDelegate { convertedValue = enumField.get(null); } catch (ClassNotFoundException ex) { - if(logger.isTraceEnabled()) { + if (logger.isTraceEnabled()) { logger.trace("Enum class [" + enumType + "] cannot be loaded", ex); } } catch (Throwable ex) { - if(logger.isTraceEnabled()) { + if (logger.isTraceEnabled()) { logger.trace("Field [" + fieldName + "] isn't an enum value for type [" + enumType + "]", ex); } } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index b6c110ea235..d058be2bb73 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -1028,7 +1028,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto if (this.dependencyComparator instanceof OrderProviderComparator) { ((OrderProviderComparator) this.dependencyComparator) .sortArray(items, createFactoryAwareOrderProvider(matchingBeans)); - } else { + } + else { Arrays.sort(items, this.dependencyComparator); } } @@ -1037,7 +1038,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto if (this.dependencyComparator instanceof OrderProviderComparator) { ((OrderProviderComparator) this.dependencyComparator) .sortList(items, createFactoryAwareOrderProvider(matchingBeans)); - } else { + } + else { Collections.sort(items, this.dependencyComparator); } } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java index 0bfcb375dab..70adeede2b2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java @@ -149,7 +149,7 @@ public abstract class AbstractSimpleBeanDefinitionParser extends AbstractSingleB */ protected boolean isEligibleAttribute(Attr attribute, ParserContext parserContext) { boolean eligible = isEligibleAttribute(attribute); - if(!eligible) { + if (!eligible) { String fullName = attribute.getName(); eligible = (!fullName.equals("xmlns") && !fullName.startsWith("xmlns:") && isEligibleAttribute(parserContext.getDelegate().getLocalName(attribute))); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandler.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandler.java index e9f4b1c22eb..420e10f27a1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandler.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,20 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.beans.factory.xml; import java.util.Collection; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.config.ConstructorArgumentValues; -import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; +import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.core.Conventions; import org.springframework.util.StringUtils; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.Node; /** * Simple {@code NamespaceHandler} implementation that maps custom @@ -34,8 +36,7 @@ import org.w3c.dom.Node; * that this {@code NamespaceHandler} does not have a corresponding schema * since there is no way to know in advance all possible attribute names. * - *

- * An example of the usage of this {@code NamespaceHandler} is shown below: + *

An example of the usage of this {@code NamespaceHandler} is shown below: * *

  * <bean id="author" class="..TestBean" c:name="Enescu" c:work-ref="compositions"/>
@@ -51,14 +52,17 @@ import org.w3c.dom.Node;
  * support for indexes or types. Further more, the names are used as hints by
  * the container which, by default, does type introspection.
  *
- * @see SimplePropertyNamespaceHandler
  * @author Costin Leau
+ * @since 3.1
+ * @see SimplePropertyNamespaceHandler
  */
 public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
 
 	private static final String REF_SUFFIX = "-ref";
+
 	private static final String DELIMITER_PREFIX = "_";
 
+
 	@Override
 	public void init() {
 	}
@@ -102,7 +106,8 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
 					int index = -1;
 					try {
 						index = Integer.parseInt(arg);
-					} catch (NumberFormatException ex) {
+					}
+					catch (NumberFormatException ex) {
 						parserContext.getReaderContext().error(
 								"Constructor argument '" + argName + "' specifies an invalid integer", attr);
 					}
@@ -136,11 +141,8 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
 	}
 
 	private boolean containsArgWithName(String name, ConstructorArgumentValues cvs) {
-		if (!checkName(name, cvs.getGenericArgumentValues())) {
-			return checkName(name, cvs.getIndexedArgumentValues().values());
-		}
-
-		return true;
+		return (checkName(name, cvs.getGenericArgumentValues()) ||
+				checkName(name, cvs.getIndexedArgumentValues().values()));
 	}
 
 	private boolean checkName(String name, Collection values) {
@@ -151,4 +153,5 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
 		}
 		return false;
 	}
+
 }
diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ResourceBundleEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ResourceBundleEditor.java
index 24467400fac..7a827c9481a 100644
--- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ResourceBundleEditor.java
+++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ResourceBundleEditor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,13 +16,13 @@
 
 package org.springframework.beans.propertyeditors;
 
-import org.springframework.util.Assert;
-import org.springframework.util.StringUtils;
-
 import java.beans.PropertyEditorSupport;
 import java.util.Locale;
 import java.util.ResourceBundle;
 
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
+
 /**
  * {@link java.beans.PropertyEditor} implementation for
  * {@link java.util.ResourceBundle ResourceBundles}.
@@ -87,7 +87,8 @@ public class ResourceBundleEditor extends PropertyEditorSupport {
 		int indexOfBaseNameSeparator = rawBaseName.indexOf(BASE_NAME_SEPARATOR);
 		if (indexOfBaseNameSeparator == -1) {
 			bundle = ResourceBundle.getBundle(rawBaseName);
-		} else {
+		}
+		else {
 			// it potentially has locale information
 			String baseName = rawBaseName.substring(0, indexOfBaseNameSeparator);
 			if (!StringUtils.hasText(baseName)) {
diff --git a/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java b/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java
index 407a346a4fa..f83d795550f 100644
--- a/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java
+++ b/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java
@@ -20,6 +20,8 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.w3c.dom.Element;
+
 import org.springframework.beans.factory.config.TypedStringValue;
 import org.springframework.beans.factory.parsing.ReaderContext;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -37,7 +39,6 @@ import org.springframework.cache.interceptor.CacheableOperation;
 import org.springframework.cache.interceptor.NameMatchCacheOperationSource;
 import org.springframework.util.StringUtils;
 import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
 
 /**
  * {@link org.springframework.beans.factory.xml.BeanDefinitionParser
@@ -75,7 +76,8 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
 			// Using attributes source.
 			List attributeSourceDefinitions = parseDefinitionsSources(cacheDefs, parserContext);
 			builder.addPropertyValue("cacheOperationSources", attributeSourceDefinitions);
-		} else {
+		}
+		else {
 			// Assume annotations source.
 			builder.addPropertyValue("cacheOperationSources", new RootBeanDefinition(
 					AnnotationCacheOperationSource.class));
@@ -178,8 +180,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
 
 	/**
 	 * Simple, reusable class used for overriding defaults.
-	 *
-	 * @author Costin Leau
 	 */
 	private static class Props {
 
@@ -195,7 +195,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
 
 		private String[] caches = null;
 
-
 		Props(Element root) {
 			String defaultCache = root.getAttribute("cache");
 			key = root.getAttribute("key");
@@ -209,7 +208,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
 			}
 		}
 
-
 		 T merge(Element element, ReaderContext readerCtx, T op) {
 			String cache = element.getAttribute("cache");
 
@@ -217,7 +215,8 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
 			String[] localCaches = caches;
 			if (StringUtils.hasText(cache)) {
 				localCaches = StringUtils.commaDelimitedListToStringArray(cache.trim());
-			} else {
+			}
+			else {
 				if (caches == null) {
 					readerCtx.error("No cache specified specified for " + element.getNodeName(), element);
 				}
@@ -240,16 +239,16 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
 		}
 
 		String merge(Element element, ReaderContext readerCtx) {
-			String m = element.getAttribute(METHOD_ATTRIBUTE);
-
-			if (StringUtils.hasText(m)) {
-				return m.trim();
-			}
+			String method = element.getAttribute(METHOD_ATTRIBUTE);
 			if (StringUtils.hasText(method)) {
-				return method;
+				return method.trim();
+			}
+			if (StringUtils.hasText(this.method)) {
+				return this.method;
 			}
 			readerCtx.error("No method specified for " + element.getNodeName(), element);
 			return null;
 		}
 	}
+
 }
diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/ExpressionEvaluator.java b/spring-context/src/main/java/org/springframework/cache/interceptor/ExpressionEvaluator.java
index 6cfaa1b4e7f..273e926c5ba 100644
--- a/spring-context/src/main/java/org/springframework/cache/interceptor/ExpressionEvaluator.java
+++ b/spring-context/src/main/java/org/springframework/cache/interceptor/ExpressionEvaluator.java
@@ -65,14 +65,11 @@ class ExpressionEvaluator {
 	// shared param discoverer since it caches data internally
 	private final ParameterNameDiscoverer paramNameDiscoverer = new DefaultParameterNameDiscoverer();
 
-	private final Map keyCache
-			= new ConcurrentHashMap(64);
+	private final Map keyCache = new ConcurrentHashMap(64);
 
-	private final Map conditionCache
-			= new ConcurrentHashMap(64);
+	private final Map conditionCache = new ConcurrentHashMap(64);
 
-	private final Map unlessCache
-			= new ConcurrentHashMap(64);
+	private final Map unlessCache = new ConcurrentHashMap(64);
 
 	private final Map targetMethodCache = new ConcurrentHashMap(64);
 
@@ -83,32 +80,32 @@ class ExpressionEvaluator {
 	 */
 	public EvaluationContext createEvaluationContext(Collection caches,
 			Method method, Object[] args, Object target, Class targetClass) {
-		return createEvaluationContext(caches, method, args, target, targetClass,
-				NO_RESULT);
+
+		return createEvaluationContext(caches, method, args, target, targetClass, NO_RESULT);
 	}
 
 	/**
 	 * Create an {@link EvaluationContext}.
-	 *
 	 * @param caches the current caches
 	 * @param method the method
 	 * @param args the method arguments
 	 * @param target the target object
 	 * @param targetClass the target class
 	 * @param result the return value (can be {@code null}) or
-	 *        {@link #NO_RESULT} if there is no return at this time
+	 * {@link #NO_RESULT} if there is no return at this time
 	 * @return the evaluation context
 	 */
 	public EvaluationContext createEvaluationContext(Collection caches,
-			Method method, Object[] args, Object target, Class targetClass,
-			final Object result) {
+			Method method, Object[] args, Object target, Class targetClass, Object result) {
+
 		CacheExpressionRootObject rootObject = new CacheExpressionRootObject(caches,
 				method, args, target, targetClass);
 		CacheEvaluationContext evaluationContext = new CacheEvaluationContext(rootObject,
 				this.paramNameDiscoverer, method, args, targetClass, this.targetMethodCache);
 		if (result == RESULT_UNAVAILABLE) {
 			evaluationContext.addUnavailableVariable(RESULT_VARIABLE);
-		} else if (result != NO_RESULT) {
+		}
+		else if (result != NO_RESULT) {
 			evaluationContext.setVariable(RESULT_VARIABLE, result);
 		}
 		return evaluationContext;
@@ -119,23 +116,21 @@ class ExpressionEvaluator {
 	}
 
 	public boolean condition(String conditionExpression, MethodCacheKey methodKey, EvaluationContext evalContext) {
-		return getExpression(this.conditionCache, conditionExpression, methodKey).getValue(
-				evalContext, boolean.class);
+		return getExpression(this.conditionCache, conditionExpression, methodKey).getValue(evalContext, boolean.class);
 	}
 
 	public boolean unless(String unlessExpression, MethodCacheKey methodKey, EvaluationContext evalContext) {
-		return getExpression(this.unlessCache, unlessExpression, methodKey).getValue(
-				evalContext, boolean.class);
+		return getExpression(this.unlessCache, unlessExpression, methodKey).getValue(evalContext, boolean.class);
 	}
 
 	private Expression getExpression(Map cache, String expression, MethodCacheKey methodKey) {
 		ExpressionKey key = createKey(methodKey, expression);
-		Expression rtn = cache.get(key);
-		if (rtn == null) {
-			rtn = this.parser.parseExpression(expression);
-			cache.put(key, rtn);
+		Expression expr = cache.get(key);
+		if (expr == null) {
+			expr = this.parser.parseExpression(expression);
+			cache.put(key, expr);
 		}
-		return rtn;
+		return expr;
 	}
 
 	private ExpressionKey createKey(MethodCacheKey methodCacheKey, String expression) {
@@ -144,10 +139,12 @@ class ExpressionEvaluator {
 
 
 	private static class ExpressionKey {
+
 		private final MethodCacheKey methodCacheKey;
+
 		private final String expression;
 
-		private ExpressionKey(MethodCacheKey methodCacheKey, String expression) {
+		public ExpressionKey(MethodCacheKey methodCacheKey, String expression) {
 			this.methodCacheKey = methodCacheKey;
 			this.expression = expression;
 		}
@@ -161,8 +158,8 @@ class ExpressionEvaluator {
 				return false;
 			}
 			ExpressionKey otherKey = (ExpressionKey) other;
-			return (this.methodCacheKey.equals(otherKey.methodCacheKey)
-					&& ObjectUtils.nullSafeEquals(this.expression, otherKey.expression));
+			return (this.methodCacheKey.equals(otherKey.methodCacheKey) &&
+					ObjectUtils.nullSafeEquals(this.expression, otherKey.expression));
 		}
 
 		@Override
diff --git a/spring-context/src/main/java/org/springframework/instrument/classloading/weblogic/WebLogicClassPreProcessorAdapter.java b/spring-context/src/main/java/org/springframework/instrument/classloading/weblogic/WebLogicClassPreProcessorAdapter.java
index e8135d799f5..c7093c7bd87 100644
--- a/spring-context/src/main/java/org/springframework/instrument/classloading/weblogic/WebLogicClassPreProcessorAdapter.java
+++ b/spring-context/src/main/java/org/springframework/instrument/classloading/weblogic/WebLogicClassPreProcessorAdapter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,32 +39,38 @@ class WebLogicClassPreProcessorAdapter implements InvocationHandler {
 
 	private final ClassLoader loader;
 
+
 	/**
 	 * Creates a new {@link WebLogicClassPreProcessorAdapter}.
-	 * @param transformer the {@link ClassFileTransformer} to be adapted (must
-	 * not be {@code null})
+	 * @param transformer the {@link ClassFileTransformer} to be adapted
+	 * (must not be {@code null})
 	 */
 	public WebLogicClassPreProcessorAdapter(ClassFileTransformer transformer, ClassLoader loader) {
 		this.transformer = transformer;
 		this.loader = loader;
 	}
 
+
 	@Override
 	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
 		String name = method.getName();
-
 		if ("equals".equals(name)) {
-			return (Boolean.valueOf(proxy == args[0]));
-		} else if ("hashCode".equals(name)) {
+			return (proxy == args[0]);
+		}
+		else if ("hashCode".equals(name)) {
 			return hashCode();
-		} else if ("toString".equals(name)) {
+		}
+		else if ("toString".equals(name)) {
 			return toString();
-		} else if ("initialize".equals(name)) {
+		}
+		else if ("initialize".equals(name)) {
 			initialize((Hashtable) args[0]);
 			return null;
-		} else if ("preProcess".equals(name)) {
+		}
+		else if ("preProcess".equals(name)) {
 			return preProcess((String) args[0], (byte[]) args[1]);
-		} else {
+		}
+		else {
 			throw new IllegalArgumentException("Unknown method: " + method);
 		}
 	}
@@ -76,16 +82,15 @@ class WebLogicClassPreProcessorAdapter implements InvocationHandler {
 		try {
 			byte[] result = this.transformer.transform(this.loader, className, null, null, classBytes);
 			return (result != null ? result : classBytes);
-		} catch (IllegalClassFormatException ex) {
+		}
+		catch (IllegalClassFormatException ex) {
 			throw new IllegalStateException("Cannot transform due to illegal class format", ex);
 		}
 	}
 
 	@Override
 	public String toString() {
-		StringBuilder builder = new StringBuilder(getClass().getName());
-		builder.append(" for transformer: ");
-		builder.append(this.transformer);
-		return builder.toString();
+		return getClass().getName() + " for transformer: " + this.transformer;
 	}
+
 }
diff --git a/spring-context/src/main/java/org/springframework/jmx/export/annotation/AnnotationJmxAttributeSource.java b/spring-context/src/main/java/org/springframework/jmx/export/annotation/AnnotationJmxAttributeSource.java
index fece173a26e..d1b02f758d1 100644
--- a/spring-context/src/main/java/org/springframework/jmx/export/annotation/AnnotationJmxAttributeSource.java
+++ b/spring-context/src/main/java/org/springframework/jmx/export/annotation/AnnotationJmxAttributeSource.java
@@ -149,7 +149,7 @@ public class AnnotationJmxAttributeSource implements JmxAttributeSource, BeanFac
 	@Override
 	public ManagedNotification[] getManagedNotifications(Class clazz) throws InvalidMetadataException {
 		ManagedNotifications notificationsAnn = clazz.getAnnotation(ManagedNotifications.class);
-		if(notificationsAnn == null) {
+		if (notificationsAnn == null) {
 			return new ManagedNotification[0];
 		}
 		Annotation[] notifications = notificationsAnn.value();
diff --git a/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractReflectiveMBeanInfoAssembler.java b/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractReflectiveMBeanInfoAssembler.java
index 3c21a8e7dd3..d49122fec7f 100644
--- a/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractReflectiveMBeanInfoAssembler.java
+++ b/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractReflectiveMBeanInfoAssembler.java
@@ -514,7 +514,7 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean
 
 		MBeanParameterInfo[] info = new MBeanParameterInfo[paramNames.length];
 		Class[] typeParameters = method.getParameterTypes();
-		for(int i = 0; i < info.length; i++) {
+		for (int i = 0; i < info.length; i++) {
 			info[i] = new MBeanParameterInfo(paramNames[i], typeParameters[i].getName(), paramNames[i]);
 		}
 
diff --git a/spring-context/src/main/java/org/springframework/jmx/export/assembler/MetadataMBeanInfoAssembler.java b/spring-context/src/main/java/org/springframework/jmx/export/assembler/MetadataMBeanInfoAssembler.java
index 32b2510901f..99cb23953b4 100644
--- a/spring-context/src/main/java/org/springframework/jmx/export/assembler/MetadataMBeanInfoAssembler.java
+++ b/spring-context/src/main/java/org/springframework/jmx/export/assembler/MetadataMBeanInfoAssembler.java
@@ -153,7 +153,7 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
 	protected boolean includeOperation(Method method, String beanKey) {
 		PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
 		if (pd != null) {
-			if(hasManagedAttribute(method)) {
+			if (hasManagedAttribute(method)) {
 				return true;
 			}
 		}
@@ -334,7 +334,7 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
 	 */
 	@Override
 	protected void populateAttributeDescriptor(Descriptor desc, Method getter, Method setter, String beanKey) {
-		if(getter != null && hasManagedMetric(getter)) {
+		if (getter != null && hasManagedMetric(getter)) {
 			populateMetricDescriptor(desc, this.attributeSource.getManagedMetric(getter));
 		}
 		else {
@@ -376,11 +376,11 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
 			desc.setField(FIELD_DISPLAY_NAME, metric.getDisplayName());
 		}
 
-		if(StringUtils.hasLength(metric.getUnit())) {
+		if (StringUtils.hasLength(metric.getUnit())) {
 			desc.setField(FIELD_UNITS, metric.getUnit());
 		}
 
-		if(StringUtils.hasLength(metric.getCategory())) {
+		if (StringUtils.hasLength(metric.getCategory())) {
 			desc.setField(FIELD_METRIC_CATEGORY, metric.getCategory());
 		}
 
diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncResult.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncResult.java
index 9b3a86a49a3..63c9d760ea7 100644
--- a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncResult.java
+++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncResult.java
@@ -83,8 +83,10 @@ public class AsyncResult implements ListenableFuture {
 	public void addCallback(SuccessCallback successCallback, FailureCallback failureCallback) {
 		try {
 			successCallback.onSuccess(this.value);
-		} catch(Throwable t) {
+		}
+		catch (Throwable t) {
 			failureCallback.onFailure(t);
 		}
 	}
+
 }
diff --git a/spring-context/src/main/java/org/springframework/validation/DefaultMessageCodesResolver.java b/spring-context/src/main/java/org/springframework/validation/DefaultMessageCodesResolver.java
index 4973f1e480b..0eee6f1bbc7 100644
--- a/spring-context/src/main/java/org/springframework/validation/DefaultMessageCodesResolver.java
+++ b/spring-context/src/main/java/org/springframework/validation/DefaultMessageCodesResolver.java
@@ -247,7 +247,7 @@ public class DefaultMessageCodesResolver implements MessageCodesResolver, Serial
 		public static String toDelimitedString(String... elements) {
 			StringBuilder rtn = new StringBuilder();
 			for (String element : elements) {
-				if(StringUtils.hasLength(element)) {
+				if (StringUtils.hasLength(element)) {
 					rtn.append(rtn.length() == 0 ? "" : CODE_SEPARATOR);
 					rtn.append(element);
 				}
diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java
index 0e93aa0141f..48e0fdc9326 100644
--- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java
+++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java
@@ -83,7 +83,7 @@ public class MethodValidationPostProcessor extends AbstractAdvisingBeanPostProce
 	 * 

Default is the default ValidatorFactory's default Validator. */ public void setValidator(Validator validator) { - if(validator instanceof LocalValidatorFactoryBean) { + if (validator instanceof LocalValidatorFactoryBean) { this.validator = ((LocalValidatorFactoryBean) validator).getValidator(); } else { diff --git a/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java b/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java index 9697aa81732..439f66b9797 100644 --- a/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java +++ b/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java @@ -155,7 +155,7 @@ abstract class SerializableTypeWrapper { return provider.getType(); } Type cached = cache.get(provider.getType()); - if(cached != null) { + if (cached != null) { return cached; } for (Class type : SUPPORTED_SERIALIZABLE_TYPES) { diff --git a/spring-core/src/main/java/org/springframework/core/convert/Property.java b/spring-core/src/main/java/org/springframework/core/convert/Property.java index 0aa414012d5..bdab6cc987b 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/Property.java +++ b/spring-core/src/main/java/org/springframework/core/convert/Property.java @@ -118,7 +118,7 @@ public final class Property { } Annotation[] getAnnotations() { - if(this.annotations == null) { + if (this.annotations == null) { this.annotations = resolveAnnotations(); } return this.annotations; @@ -192,7 +192,7 @@ public final class Property { private Annotation[] resolveAnnotations() { Annotation[] annotations = annotationCache.get(this); - if(annotations == null) { + if (annotations == null) { Map, Annotation> annotationMap = new LinkedHashMap, Annotation>(); addAnnotationsToMap(annotationMap, getReadMethod()); addAnnotationsToMap(annotationMap, getWriteMethod()); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java index eadacf30713..12228156170 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java @@ -78,7 +78,7 @@ final class MapToMapConverter implements ConditionalGenericConverter { copyRequired = true; } } - if(!copyRequired) { + if (!copyRequired) { return sourceMap; } Map targetMap = CollectionFactory.createMap(targetType.getType(), sourceMap.size()); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/StringToCollectionConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/StringToCollectionConverter.java index 2049dca6b80..9c23d2c7690 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/StringToCollectionConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/StringToCollectionConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,8 @@ import org.springframework.util.StringUtils; /** * Converts a comma-delimited String to a Collection. - * If the target collection element type is declared, only matches if String.class can be converted to it. + * If the target collection element type is declared, only matches if + * {@code String.class} can be converted to it. * * @author Keith Donald * @since 3.0 @@ -37,10 +38,12 @@ final class StringToCollectionConverter implements ConditionalGenericConverter { private final ConversionService conversionService; + public StringToCollectionConverter(ConversionService conversionService) { this.conversionService = conversionService; } + @Override public Set getConvertibleTypes() { return Collections.singleton(new ConvertiblePair(String.class, Collection.class)); @@ -48,11 +51,8 @@ final class StringToCollectionConverter implements ConditionalGenericConverter { @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { - if (targetType.getElementTypeDescriptor() != null) { - return this.conversionService.canConvert(sourceType, targetType.getElementTypeDescriptor()); - } else { - return true; - } + return (targetType.getElementTypeDescriptor() == null || + this.conversionService.canConvert(sourceType, targetType.getElementTypeDescriptor())); } @Override @@ -67,7 +67,8 @@ final class StringToCollectionConverter implements ConditionalGenericConverter { for (String field : fields) { target.add(field.trim()); } - } else { + } + else { for (String field : fields) { Object targetElement = this.conversionService.convert(field.trim(), sourceType, targetType.getElementTypeDescriptor()); target.add(targetElement); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java b/spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java index 09fbc8f6500..7fec5eb48f8 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package org.springframework.core.convert.support; import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.ConverterFactory; -import org.springframework.util.Assert; /** * Converts from a String to a java.lang.Enum by calling {@link Enum#valueOf(Class, String)}. @@ -32,14 +31,16 @@ final class StringToEnumConverterFactory implements ConverterFactory Converter getConverter(Class targetType) { Class enumType = targetType; - while(enumType != null && !enumType.isEnum()) { + while (enumType != null && !enumType.isEnum()) { enumType = enumType.getSuperclass(); } - Assert.notNull(enumType, "The target type " + targetType.getName() - + " does not refer to an enum"); + if (enumType == null) { + throw new IllegalArgumentException("The target type " + targetType.getName() + " does not refer to an enum"); + } return new StringToEnum(enumType); } + private class StringToEnum implements Converter { private final Class enumType; diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java index b97335a83b5..48e6a0aef2e 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java @@ -31,7 +31,7 @@ final class StringToUUIDConverter implements Converter { @Override public UUID convert(String source) { - if(StringUtils.hasLength(source)) { + if (StringUtils.hasLength(source)) { return UUID.fromString(source.trim()); } return null; diff --git a/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java b/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java index 8dd0e7d57ad..cd00102035f 100644 --- a/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,7 +129,7 @@ public abstract class AbstractResource implements Resource { long size = 0; byte[] buf = new byte[255]; int read; - while((read = is.read(buf)) != -1) { + while ((read = is.read(buf)) != -1) { size += read; } return size; diff --git a/spring-core/src/main/java/org/springframework/core/io/PathResource.java b/spring-core/src/main/java/org/springframework/core/io/PathResource.java index 52fd8d74414..8dfd0447edd 100644 --- a/spring-core/src/main/java/org/springframework/core/io/PathResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/PathResource.java @@ -226,7 +226,7 @@ public class PathResource extends AbstractResource implements WritableResource { */ @Override public OutputStream getOutputStream() throws IOException { - if(Files.isDirectory(this.path)) { + if (Files.isDirectory(this.path)) { throw new FileNotFoundException(getPath() + " (is a directory)"); } return Files.newOutputStream(this.path); diff --git a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java index 22c2f4d888d..db35b7195ac 100644 --- a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java +++ b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java @@ -709,16 +709,16 @@ public class AntPathMatcher implements PathMatcher { protected void initCounters() { int pos = 0; while (pos < this.pattern.length()) { - if(this.pattern.charAt(pos) == '{') { + if (this.pattern.charAt(pos) == '{') { this.uriVars++; pos++; } - else if(this.pattern.charAt(pos) == '*') { - if(pos + 1 < this.pattern.length() && this.pattern.charAt(pos + 1) == '*') { + else if (this.pattern.charAt(pos) == '*') { + if (pos + 1 < this.pattern.length() && this.pattern.charAt(pos + 1) == '*') { this.doubleWildcards++; pos += 2; } - else if(!this.pattern.substring(pos - 1).equals(".*")) { + else if (!this.pattern.substring(pos - 1).equals(".*")) { this.singleWildcards++; pos++; } diff --git a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java index 5d6b9c5e5d6..218d43fd3b8 100644 --- a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java @@ -155,7 +155,7 @@ public abstract class ObjectUtils { */ public static > E caseInsensitiveValueOf(E[] enumValues, String constant) { for (E candidate : enumValues) { - if(candidate.toString().equalsIgnoreCase(constant)) { + if (candidate.toString().equalsIgnoreCase(constant)) { return candidate; } } diff --git a/spring-core/src/main/java/org/springframework/util/SocketUtils.java b/spring-core/src/main/java/org/springframework/util/SocketUtils.java index 28444526ad8..ec44c24fa8a 100644 --- a/spring-core/src/main/java/org/springframework/util/SocketUtils.java +++ b/spring-core/src/main/java/org/springframework/util/SocketUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,25 +58,18 @@ public abstract class SocketUtils { /** * Although {@code SocketUtils} consists solely of static utility methods, * this constructor is intentionally {@code public}. - * *

Rationale

- * *

Static methods from this class may be invoked from within XML * configuration files using the Spring Expression Language (SpEL) and the * following syntax. - * *

<bean id="bean1" ... p:port="#{T(org.springframework.util.SocketUtils).findAvailableTcpPort(12000)}" />
- * * If this constructor were {@code private}, you would be required to supply * the fully qualified class name to SpEL's {@code T()} function for each usage. * Thus, the fact that this constructor is {@code public} allows you to reduce * boilerplate configuration with SpEL as can be seen in the following example. - * *
<bean id="socketUtils" class="org.springframework.util.SocketUtils" />
-	 *
-	 *<bean id="bean1" ... p:port="#{socketUtils.findAvailableTcpPort(12000)}" />
-	 *
-	 *<bean id="bean2" ... p:port="#{socketUtils.findAvailableTcpPort(30000)}" />
+ * <bean id="bean1" ... p:port="#{socketUtils.findAvailableTcpPort(12000)}" /> + * <bean id="bean2" ... p:port="#{socketUtils.findAvailableTcpPort(30000)}" />
*/ public SocketUtils() { /* no-op */ @@ -271,7 +264,8 @@ public abstract class SocketUtils { maxPort, searchCounter)); } candidatePort = findRandomPort(minPort, maxPort); - } while (!isPortAvailable(candidatePort)); + } + while (!isPortAvailable(candidatePort)); return candidatePort; } diff --git a/spring-core/src/main/java/org/springframework/util/StopWatch.java b/spring-core/src/main/java/org/springframework/util/StopWatch.java index 1f7552b57a7..0c974991134 100644 --- a/spring-core/src/main/java/org/springframework/util/StopWatch.java +++ b/spring-core/src/main/java/org/springframework/util/StopWatch.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -229,7 +229,8 @@ public class StopWatch { sb.append('\n'); if (!this.keepTaskList) { sb.append("No task info kept"); - } else { + } + else { sb.append("-----------------------------------------\n"); sb.append("ms % Task name\n"); sb.append("-----------------------------------------\n"); @@ -261,7 +262,8 @@ public class StopWatch { long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds()); sb.append(" = ").append(percent).append("%"); } - } else { + } + else { sb.append("; no task info kept"); } return sb.toString(); diff --git a/spring-core/src/main/java/org/springframework/util/comparator/InstanceComparator.java b/spring-core/src/main/java/org/springframework/util/comparator/InstanceComparator.java index b9c6161038d..04c8edfa941 100644 --- a/spring-core/src/main/java/org/springframework/util/comparator/InstanceComparator.java +++ b/spring-core/src/main/java/org/springframework/util/comparator/InstanceComparator.java @@ -60,7 +60,7 @@ public class InstanceComparator implements Comparator { } private int getOrder(T object) { - if(object != null) { + if (object != null) { for (int i = 0; i < instanceOrder.length; i++) { if (instanceOrder[i].isInstance(object)) { return i; diff --git a/spring-core/src/main/java/org/springframework/util/concurrent/FutureAdapter.java b/spring-core/src/main/java/org/springframework/util/concurrent/FutureAdapter.java index dce61439639..b0c6e182831 100644 --- a/spring-core/src/main/java/org/springframework/util/concurrent/FutureAdapter.java +++ b/spring-core/src/main/java/org/springframework/util/concurrent/FutureAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,10 +29,10 @@ import org.springframework.util.Assert; * #get()} and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's * result. * - * @param the type of this {@code Future} - * @param the type of the adaptee's {@code Future} * @author Arjen Poutsma * @since 4.0 + * @param the type of this {@code Future} + * @param the type of the adaptee's {@code Future} */ public abstract class FutureAdapter implements Future { @@ -44,6 +44,7 @@ public abstract class FutureAdapter implements Future { private final Object mutex = new Object(); + /** * Constructs a new {@code FutureAdapter} with the given adaptee. * @param adaptee the future to delegate to @@ -53,6 +54,7 @@ public abstract class FutureAdapter implements Future { this.adaptee = adaptee; } + /** * Returns the adaptee. */ @@ -81,28 +83,28 @@ public abstract class FutureAdapter implements Future { } @Override - public T get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - return adaptInternal(adaptee.get(timeout, unit)); + public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + return adaptInternal(this.adaptee.get(timeout, unit)); } @SuppressWarnings("unchecked") final T adaptInternal(S adapteeResult) throws ExecutionException { - synchronized (mutex) { - switch (state) { + synchronized (this.mutex) { + switch (this.state) { case SUCCESS: - return (T) result; + return (T) this.result; case FAILURE: - throw (ExecutionException) result; + throw (ExecutionException) this.result; case NEW: try { T adapted = adapt(adapteeResult); - result = adapted; - state = State.SUCCESS; + this.result = adapted; + this.state = State.SUCCESS; return adapted; - } catch (ExecutionException ex) { - result = ex; - state = State.FAILURE; + } + catch (ExecutionException ex) { + this.result = ex; + this.state = State.FAILURE; throw ex; } default: @@ -117,6 +119,7 @@ public abstract class FutureAdapter implements Future { */ protected abstract T adapt(S adapteeResult) throws ExecutionException; + private enum State {NEW, SUCCESS, FAILURE} } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java index b77920bd51c..26a47af200d 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java @@ -219,47 +219,48 @@ public class CodeFlow implements Opcodes { * @return the JVM descriptor for the class */ public static String toJVMDescriptor(Class clazz) { - StringBuilder s= new StringBuilder(); + StringBuilder sb = new StringBuilder(); if (clazz.isArray()) { while (clazz.isArray()) { - s.append("["); + sb.append("["); clazz = clazz.getComponentType(); } } if (clazz.isPrimitive()) { if (clazz == Void.TYPE) { - s.append('V'); + sb.append('V'); } else if (clazz == Integer.TYPE) { - s.append('I'); + sb.append('I'); } else if (clazz == Boolean.TYPE) { - s.append('Z'); + sb.append('Z'); } else if (clazz == Character.TYPE) { - s.append('C'); + sb.append('C'); } else if (clazz == Long.TYPE) { - s.append('J'); + sb.append('J'); } else if (clazz == Double.TYPE) { - s.append('D'); + sb.append('D'); } else if (clazz == Float.TYPE) { - s.append('F'); + sb.append('F'); } else if (clazz == Byte.TYPE) { - s.append('B'); + sb.append('B'); } else if (clazz == Short.TYPE) { - s.append('S'); + sb.append('S'); } - } else { - s.append("L"); - s.append(clazz.getName().replace('.', '/')); - s.append(";"); } - return s.toString(); + else { + sb.append("L"); + sb.append(clazz.getName().replace('.', '/')); + sb.append(";"); + } + return sb.toString(); } /** diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java index 6ddfe998ce1..1ecc46ac5c3 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java @@ -283,7 +283,8 @@ public class Indexer extends SpelNodeImpl { } if (member instanceof Field) { mv.visitFieldInsn(isStatic?GETSTATIC:GETFIELD,memberDeclaringClassSlashedDescriptor,member.getName(),CodeFlow.toJVMDescriptor(((Field) member).getType())); - } else { + } + else { mv.visitMethodInsn(isStatic?INVOKESTATIC:INVOKEVIRTUAL, memberDeclaringClassSlashedDescriptor, member.getName(),CodeFlow.createSignatureDescriptor((Method)member),false); } } @@ -556,12 +557,12 @@ public class Indexer extends SpelNodeImpl { Member member = optimalAccessor.member; if (member instanceof Field) { Indexer.this.exitTypeDescriptor = CodeFlow.toDescriptor(((Field)member).getType()); - } else { + } + else { Indexer.this.exitTypeDescriptor = CodeFlow.toDescriptor(((Method)member).getReturnType()); } } - TypedValue value = accessor.read(this.evaluationContext, this.targetObject, this.name); - return value; + return accessor.read(this.evaluationContext, this.targetObject, this.name); } } } @@ -679,7 +680,7 @@ public class Indexer extends SpelNodeImpl { throw new SpelEvaluationException(getStartPosition(), SpelMessage.COLLECTION_INDEX_OUT_OF_BOUNDS, this.collection.size(), this.index); } - if(this.index >= this.maximumSize) { + if (this.index >= this.maximumSize) { throw new SpelEvaluationException(getStartPosition(), SpelMessage.UNABLE_TO_GROW_COLLECTION); } if (this.collectionEntryDescriptor.getElementTypeDescriptor() == null) { diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java index e71ad7eca1d..a20a6ea28af 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java @@ -105,7 +105,8 @@ public class OpEQ extends Operator { else { throw new IllegalStateException("Unexpected descriptor "+leftDesc); } - } else { + } + else { getLeftOperand().generateCode(mv, codeflow); getRightOperand().generateCode(mv, codeflow); Label leftNotNull = new Label(); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java index 615f4b8084d..8d1fbdb51e2 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java @@ -193,7 +193,8 @@ public class OpMinus extends Operator { default: throw new IllegalStateException("Unrecognized exit descriptor: '"+this.exitTypeDescriptor+"'"); } - } else { + } + else { switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(INEG); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java index a92159d746a..61c17f60acc 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java @@ -105,7 +105,8 @@ public class OpNE extends Operator { else { throw new IllegalStateException("Unexpected descriptor "+leftDesc); } - } else { + } + else { getLeftOperand().generateCode(mv, codeflow); getRightOperand().generateCode(mv, codeflow); mv.visitJumpInsn(IF_ACMPEQ, elseTarget); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java index 002a90a9d92..231615e5f4c 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java @@ -66,7 +66,8 @@ public class OperatorInstanceof extends Operator { Class rightClass = (Class) rightValue; if (leftValue == null) { result = BooleanTypedValue.FALSE; // null is not an instanceof anything - } else { + } + else { result = BooleanTypedValue.forValue(rightClass.isAssignableFrom(leftValue.getClass())); } this.type = rightClass; @@ -76,7 +77,7 @@ public class OperatorInstanceof extends Operator { @Override public boolean isCompilable() { - return this.exitTypeDescriptor != null && getLeftOperand().isCompilable(); + return (this.exitTypeDescriptor != null && getLeftOperand().isCompilable()); } @Override @@ -85,4 +86,5 @@ public class OperatorInstanceof extends Operator { mv.visitTypeInsn(INSTANCEOF,Type.getInternalName(this.type)); codeflow.pushDescriptor(getExitDescriptor()); } + } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java index 6b7c2c1f886..11c475b460d 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java @@ -36,6 +36,7 @@ public class TypeReference extends SpelNodeImpl { private transient Class type; + public TypeReference(int pos, SpelNodeImpl qualifiedId) { this(pos,qualifiedId,0); } @@ -50,7 +51,7 @@ public class TypeReference extends SpelNodeImpl { public TypedValue getValueInternal(ExpressionState state) throws EvaluationException { // TODO possible optimization here if we cache the discovered type reference, but can we do that? String typename = (String) this.children[0].getValueInternal(state).getValue(); - if (typename.indexOf(".") == -1 && Character.isLowerCase(typename.charAt(0))) { + if (typename.indexOf('.') == -1 && Character.isLowerCase(typename.charAt(0))) { TypeCode tc = TypeCode.valueOf(typename.toUpperCase()); if (tc != TypeCode.OBJECT) { // it is a primitive type @@ -69,10 +70,10 @@ public class TypeReference extends SpelNodeImpl { } private Class makeArrayIfNecessary(Class clazz) { - if (this.dimensions!=0) { - for (int i=0;i listElements = new ArrayList(); do { listElements.add(eatExpression()); - } while (peekToken(TokenKind.COMMA,true)); + } + while (peekToken(TokenKind.COMMA,true)); closingCurly = eatToken(TokenKind.RCURLY); expr = new InlineList(toPos(t.startpos,closingCurly.endpos),listElements.toArray(new SpelNodeImpl[listElements.size()])); @@ -640,7 +643,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { } nextToken(); SpelNodeImpl expr = eatExpression(); - if(expr == null) { + if (expr == null) { raiseInternalException(toPos(t), SpelMessage.MISSING_SELECTION_EXPRESSION); } eatToken(TokenKind.RSQUARE); @@ -665,13 +668,13 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { Token node = peekToken(); while (isValidQualifiedId(node)) { nextToken(); - if(node.kind != TokenKind.DOT) { + if (node.kind != TokenKind.DOT) { qualifiedIdPieces.add(new Identifier(node.stringValue(),toPos(node))); } node = peekToken(); } - if(qualifiedIdPieces.isEmpty()) { - if(node == null) { + if (qualifiedIdPieces.isEmpty()) { + if (node == null) { raiseInternalException( this.expressionString.length(), SpelMessage.OOD); } raiseInternalException(node.startpos, SpelMessage.NOT_EXPECTED_TOKEN, @@ -682,10 +685,10 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { } private boolean isValidQualifiedId(Token node) { - if(node == null || node.kind == TokenKind.LITERAL_STRING) { + if (node == null || node.kind == TokenKind.LITERAL_STRING) { return false; } - if(node.kind == TokenKind.DOT || node.kind == TokenKind.IDENTIFIER) { + if (node.kind == TokenKind.DOT || node.kind == TokenKind.IDENTIFIER) { return true; } String value = node.stringValue(); @@ -708,9 +711,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { // TODO what is the end position for a method reference? the name or the last arg? return true; } - return false; - } //constructor @@ -825,7 +826,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { // | GREATER_THAN_OR_EQUAL | INSTANCEOF | BETWEEN | MATCHES private Token maybeEatRelationalOperator() { Token t = peekToken(); - if (t==null) { + if (t == null) { return null; } if (t.isNumericRelationalOperator()) { @@ -848,10 +849,10 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { private Token eatToken(TokenKind expectedKind) { Token t = nextToken(); - if (t==null) { + if (t == null) { raiseInternalException( this.expressionString.length(), SpelMessage.OOD); } - if (t.kind!=expectedKind) { + if (t.kind != expectedKind) { raiseInternalException(t.startpos,SpelMessage.NOT_EXPECTED_TOKEN, expectedKind.toString().toLowerCase(),t.getKind().toString().toLowerCase()); } return t; @@ -866,7 +867,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { return false; } Token t = peekToken(); - if (t.kind==desiredTokenKind) { + if (t.kind == desiredTokenKind) { if (consumeIfMatched) { this.tokenStreamPointer++; } @@ -876,7 +877,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { if (desiredTokenKind == TokenKind.IDENTIFIER) { // might be one of the textual forms of the operators (e.g. NE for != ) - in which case we can treat it as an identifier // The list is represented here: Tokenizer.alternativeOperatorNames and those ones are in order in the TokenKind enum - if (t.kind.ordinal()>=TokenKind.DIV.ordinal() && t.kind.ordinal()<=TokenKind.NOT.ordinal() && t.data!=null) { + if (t.kind.ordinal() >= TokenKind.DIV.ordinal() && t.kind.ordinal() <= TokenKind.NOT.ordinal() && t.data != null) { // if t.data were null, we'd know it wasn't the textual form, it was the symbol form return true; } @@ -889,7 +890,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { return false; } Token t = peekToken(); - return t.kind == possible1 || t.kind == possible2; + return (t.kind == possible1 || t.kind == possible2); } private boolean peekToken(TokenKind possible1,TokenKind possible2, TokenKind possible3) { @@ -965,14 +966,14 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { } /** - * Compress the start and end of a token into a single int + * Compress the start and end of a token into a single int. */ private int toPos(Token t) { - return (t.startpos<<16)+t.endpos; + return (t.startpos<<16) + t.endpos; } private int toPos(int start,int end) { - return (start<<16)+end; + return (start<<16) + end; } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java index f7e10098641..49f93ae9c7c 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java @@ -117,7 +117,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { else if (isStoresUpperCaseIdentifiers()) { return procedureName.toUpperCase(); } - else if(isStoresLowerCaseIdentifiers()) { + else if (isStoresLowerCaseIdentifiers()) { return procedureName.toLowerCase(); } else { @@ -133,7 +133,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { else if (isStoresUpperCaseIdentifiers()) { return catalogName.toUpperCase(); } - else if(isStoresLowerCaseIdentifiers()) { + else if (isStoresLowerCaseIdentifiers()) { return catalogName.toLowerCase(); } else { @@ -149,7 +149,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { else if (isStoresUpperCaseIdentifiers()) { return schemaName.toUpperCase(); } - else if(isStoresLowerCaseIdentifiers()) { + else if (isStoresLowerCaseIdentifiers()) { return schemaName.toLowerCase(); } else { @@ -185,7 +185,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { else if (isStoresUpperCaseIdentifiers()) { return parameterName.toUpperCase(); } - else if(isStoresLowerCaseIdentifiers()) { + else if (isStoresLowerCaseIdentifiers()) { return parameterName.toLowerCase(); } else { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java index adb09f082c5..24e66c42fe4 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,34 +85,23 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { } - /** - * Specify whether identifiers use upper case - */ public void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers) { this.storesUpperCaseIdentifiers = storesUpperCaseIdentifiers; } - /** - * Get whether identifiers use upper case - */ public boolean isStoresUpperCaseIdentifiers() { return this.storesUpperCaseIdentifiers; } - /** - * Specify whether identifiers use lower case. - */ public void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers) { this.storesLowerCaseIdentifiers = storesLowerCaseIdentifiers; } - /** - * Get whether identifiers use lower case - */ public boolean isStoresLowerCaseIdentifiers() { return this.storesLowerCaseIdentifiers; } + @Override public boolean isTableColumnMetaDataUsed() { return this.tableColumnMetaDataUsed; @@ -138,16 +127,10 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { return null; } - /** - * Specify whether a column name array is supported for generated keys - */ public void setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported) { this.getGeneratedKeysSupported = getGeneratedKeysSupported; } - /** - * Specify whether a column name array is supported for generated keys - */ public void setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported) { this.generatedKeysColumnNameArraySupported = generatedKeysColumnNameArraySupported; } @@ -179,8 +162,8 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { setGetGeneratedKeysSupported(false); } } - catch (SQLException se) { - logger.warn("Error retrieving 'DatabaseMetaData.getGeneratedKeys' - " + se.getMessage()); + catch (SQLException ex) { + logger.warn("Error retrieving 'DatabaseMetaData.getGeneratedKeys' - " + ex.getMessage()); } try { String databaseProductName = databaseMetaData.getDatabaseProductName(); @@ -198,26 +181,26 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { } } } - catch (SQLException se) { - logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductName' - " + se.getMessage()); + catch (SQLException ex) { + logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductName' - " + ex.getMessage()); } try { this.databaseVersion = databaseMetaData.getDatabaseProductVersion(); } - catch (SQLException se) { - logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductVersion' - " + se.getMessage()); + catch (SQLException ex) { + logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductVersion' - " + ex.getMessage()); } try { setStoresUpperCaseIdentifiers(databaseMetaData.storesUpperCaseIdentifiers()); } - catch (SQLException se) { - logger.warn("Error retrieving 'DatabaseMetaData.storesUpperCaseIdentifiers' - " + se.getMessage()); + catch (SQLException ex) { + logger.warn("Error retrieving 'DatabaseMetaData.storesUpperCaseIdentifiers' - " + ex.getMessage()); } try { setStoresLowerCaseIdentifiers(databaseMetaData.storesLowerCaseIdentifiers()); } - catch (SQLException se) { - logger.warn("Error retrieving 'DatabaseMetaData.storesLowerCaseIdentifiers' - " + se.getMessage()); + catch (SQLException ex) { + logger.warn("Error retrieving 'DatabaseMetaData.storesLowerCaseIdentifiers' - " + ex.getMessage()); } } @@ -238,7 +221,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { else if (isStoresUpperCaseIdentifiers()) { return tableName.toUpperCase(); } - else if(isStoresLowerCaseIdentifiers()) { + else if (isStoresLowerCaseIdentifiers()) { return tableName.toLowerCase(); } else { @@ -254,7 +237,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { else if (isStoresUpperCaseIdentifiers()) { return catalogName.toUpperCase(); } - else if(isStoresLowerCaseIdentifiers()) { + else if (isStoresLowerCaseIdentifiers()) { return catalogName.toLowerCase(); } else { @@ -270,7 +253,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { else if (isStoresUpperCaseIdentifiers()) { return schemaName.toUpperCase(); } - else if(isStoresLowerCaseIdentifiers()) { + else if (isStoresLowerCaseIdentifiers()) { return schemaName.toLowerCase(); } else { @@ -325,22 +308,23 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { tmd.setSchemaName(tables.getString("TABLE_SCHEM")); tmd.setTableName(tables.getString("TABLE_NAME")); if (tmd.getSchemaName() == null) { - tableMeta.put(userName != null ? userName.toUpperCase() : "", tmd); + tableMeta.put(this.userName != null ? this.userName.toUpperCase() : "", tmd); } else { tableMeta.put(tmd.getSchemaName().toUpperCase(), tmd); } } } - catch (SQLException se) { - logger.warn("Error while accessing table meta data results" + se.getMessage()); + catch (SQLException ex) { + logger.warn("Error while accessing table meta data results" + ex.getMessage()); } finally { if (tables != null) { try { tables.close(); - } catch (SQLException e) { - logger.warn("Error while closing table meta data results" + e.getMessage()); + } + catch (SQLException ex) { + logger.warn("Error while closing table meta data results" + ex.getMessage()); } } } @@ -431,16 +415,16 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { } } } - catch (SQLException se) { - logger.warn("Error while retrieving metadata for table columns: " + se.getMessage()); + catch (SQLException ex) { + logger.warn("Error while retrieving metadata for table columns: " + ex.getMessage()); } finally { try { if (tableColumns != null) tableColumns.close(); } - catch (SQLException se) { - logger.warn("Problem closing ResultSet for table column metadata " + se.getMessage()); + catch (SQLException ex) { + logger.warn("Problem closing ResultSet for table column metadata " + ex.getMessage()); } } @@ -458,7 +442,6 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { private String tableName; - public void setCatalogName(String catalogName) { this.catalogName = catalogName; } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java index 9dd2eba0a67..f9bccb8d3b0 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java @@ -94,7 +94,7 @@ public abstract class AbstractExceptionHandlerMethodResolver { */ private Method getMappedMethod(Class exceptionType) { List> matches = new ArrayList>(); - for(Class mappedException : this.mappedMethods.keySet()) { + for (Class mappedException : this.mappedMethods.keySet()) { if (mappedException.isAssignableFrom(exceptionType)) { matches.add(mappedException); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpSessionScope.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpSessionScope.java index 0e3c0f04a99..7507bfc920d 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpSessionScope.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpSessionScope.java @@ -56,7 +56,8 @@ public class SimpSessionScope implements Scope { if (value != null) { simpAttributes.removeAttribute(name); return value; - } else { + } + else { return null; } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java index d1a95a8aebd..6ac962e4d20 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java @@ -312,7 +312,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { public void addSubscription(String destination, String subscriptionId) { Set subs = this.subscriptions.get(destination); if (subs == null) { - synchronized(this.monitor) { + synchronized (this.monitor) { subs = this.subscriptions.get(destination); if (subs == null) { subs = new HashSet(4); @@ -327,7 +327,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { for (String destination : this.subscriptions.keySet()) { Set subscriptionIds = this.subscriptions.get(destination); if (subscriptionIds.remove(subscriptionId)) { - synchronized(this.monitor) { + synchronized (this.monitor) { if (subscriptionIds.isEmpty()) { this.subscriptions.remove(destination); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java index e5c0c204585..a3914a1818f 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java @@ -316,7 +316,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC protected Validator simpValidator() { Validator validator = getValidator(); if (validator == null) { - if(this.applicationContext.containsBean(MVC_VALIDATOR_NAME)) { + if (this.applicationContext.containsBean(MVC_VALIDATOR_NAME)) { validator = this.applicationContext.getBean(MVC_VALIDATOR_NAME, Validator.class); } else if (ClassUtils.isPresent("javax.validation.Validator", getClass().getClassLoader())) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/StompBrokerRelayRegistration.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/StompBrokerRelayRegistration.java index dc10a927532..c0580f18163 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/StompBrokerRelayRegistration.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/StompBrokerRelayRegistration.java @@ -192,7 +192,7 @@ public class StompBrokerRelayRegistration extends AbstractBrokerRegistration { if (this.systemHeartbeatReceiveInterval != null) { handler.setSystemHeartbeatReceiveInterval(this.systemHeartbeatReceiveInterval); } - if(this.virtualHost != null) { + if (this.virtualHost != null) { handler.setVirtualHost(this.virtualHost); } diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java index 395442fee68..525197336a2 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java @@ -535,7 +535,7 @@ public class MockHttpServletResponse implements HttpServletResponse { @Override public void setStatus(int status) { - if(!this.isCommitted()) { + if (!this.isCommitted()) { this.status = status; } } @@ -543,7 +543,7 @@ public class MockHttpServletResponse implements HttpServletResponse { @Override @Deprecated public void setStatus(int status, String errorMessage) { - if(!this.isCommitted()) { + if (!this.isCommitted()) { this.status = status; this.errorMessage = errorMessage; } diff --git a/spring-test/src/main/java/org/springframework/test/context/support/AbstractDelegatingSmartContextLoader.java b/spring-test/src/main/java/org/springframework/test/context/support/AbstractDelegatingSmartContextLoader.java index 95f093bf897..1f12c293257 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/AbstractDelegatingSmartContextLoader.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/AbstractDelegatingSmartContextLoader.java @@ -78,6 +78,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte */ protected abstract SmartContextLoader getAnnotationConfigLoader(); + // --- SmartContextLoader -------------------------------------------------- private static String name(SmartContextLoader loader) { @@ -94,6 +95,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte private static ApplicationContext delegateLoading(SmartContextLoader loader, MergedContextConfiguration mergedConfig) throws Exception { + if (logger.isDebugEnabled()) { logger.debug(String.format("Delegating to %s to load context from %s.", name(loader), mergedConfig)); } @@ -103,7 +105,8 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte private boolean supports(SmartContextLoader loader, MergedContextConfiguration mergedConfig) { if (loader == getAnnotationConfigLoader()) { return ObjectUtils.isEmpty(mergedConfig.getLocations()) && !ObjectUtils.isEmpty(mergedConfig.getClasses()); - } else { + } + else { return !ObjectUtils.isEmpty(mergedConfig.getLocations()) && ObjectUtils.isEmpty(mergedConfig.getClasses()); } } @@ -111,12 +114,10 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte /** * Delegates to candidate {@code SmartContextLoaders} to process the supplied * {@link ContextConfigurationAttributes}. - * *

Delegation is based on explicit knowledge of the implementations of the * default loaders for {@link #getXmlLoader() XML configuration files} and * {@link #getAnnotationConfigLoader() annotated classes}. Specifically, the * delegation algorithm is as follows: - * *

    *
  • If the resource locations or annotated classes in the supplied * {@code ContextConfigurationAttributes} are not empty, the appropriate @@ -131,7 +132,6 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte * If the annotation-based loader detects default configuration * classes, an {@code info} message will be logged.
  • *
- * * @param configAttributes the context configuration attributes to process * @throws IllegalArgumentException if the supplied configuration attributes are * {@code null}, or if the supplied configuration attributes include both @@ -147,17 +147,19 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte Assert.notNull(configAttributes, "configAttributes must not be null"); Assert.isTrue(!(configAttributes.hasLocations() && configAttributes.hasClasses()), String.format( - "Cannot process locations AND classes for context " - + "configuration %s; configure one or the other, but not both.", configAttributes)); + "Cannot process locations AND classes for context configuration %s; configure one or the other, but not both.", + configAttributes)); // If the original locations or classes were not empty, there's no // need to bother with default detection checks; just let the // appropriate loader process the configuration. if (configAttributes.hasLocations()) { delegateProcessing(getXmlLoader(), configAttributes); - } else if (configAttributes.hasClasses()) { + } + else if (configAttributes.hasClasses()) { delegateProcessing(getAnnotationConfigLoader(), configAttributes); - } else { + } + else { // Else attempt to detect defaults... // Let the XML loader process the configuration. @@ -198,15 +200,15 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte // throw an exception. if (!configAttributes.hasResources() && ObjectUtils.isEmpty(configAttributes.getInitializers())) { throw new IllegalStateException(String.format( - "Neither %s nor %s was able to detect defaults, and no ApplicationContextInitializers " - + "were declared for context configuration %s", name(getXmlLoader()), + "Neither %s nor %s was able to detect defaults, and no ApplicationContextInitializers " + + "were declared for context configuration %s", name(getXmlLoader()), name(getAnnotationConfigLoader()), configAttributes)); } if (configAttributes.hasLocations() && configAttributes.hasClasses()) { String message = String.format( - "Configuration error: both default locations AND default configuration classes " - + "were detected for context configuration %s; configure one or the other, but not both.", + "Configuration error: both default locations AND default configuration classes " + + "were detected for context configuration %s; configure one or the other, but not both.", configAttributes); logger.error(message); throw new IllegalStateException(message); @@ -217,12 +219,10 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte /** * Delegates to an appropriate candidate {@code SmartContextLoader} to load * an {@link ApplicationContext}. - * *

Delegation is based on explicit knowledge of the implementations of the * default loaders for {@link #getXmlLoader() XML configuration files} and * {@link #getAnnotationConfigLoader() annotated classes}. Specifically, the * delegation algorithm is as follows: - * *

    *
  • If the resource locations in the supplied {@code MergedContextConfiguration} * are not empty and the annotated classes are empty, @@ -231,7 +231,6 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte * are not empty and the resource locations are empty, * the annotation-based loader will load the {@code ApplicationContext}.
  • *
- * * @param mergedConfig the merged context configuration to use to load the application context * @throws IllegalArgumentException if the supplied merged configuration is {@code null} * @throws IllegalStateException if neither candidate loader is capable of loading an @@ -240,7 +239,6 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte @Override public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception { Assert.notNull(mergedConfig, "mergedConfig must not be null"); - List candidates = Arrays.asList(getXmlLoader(), getAnnotationConfigLoader()); for (SmartContextLoader loader : candidates) { @@ -262,6 +260,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte name(getAnnotationConfigLoader()), mergedConfig)); } + // --- ContextLoader ------------------------------------------------------- /** @@ -272,8 +271,8 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte */ @Override public final String[] processLocations(Class clazz, String... locations) { - throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. " - + "Call processContextConfiguration(ContextConfigurationAttributes) instead."); + throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. " + + "Call processContextConfiguration(ContextConfigurationAttributes) instead."); } /** @@ -284,8 +283,8 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte */ @Override public final ApplicationContext loadContext(String... locations) throws Exception { - throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. " - + "Call loadContext(MergedContextConfiguration) instead."); + throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. " + + "Call loadContext(MergedContextConfiguration) instead."); } } diff --git a/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java b/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java index 9b247990d18..db38ef36d36 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.context.annotation.Configuration; import org.springframework.test.context.SmartContextLoader; import org.springframework.util.Assert; @@ -38,45 +39,12 @@ public abstract class AnnotationConfigContextLoaderUtils { private static final Log logger = LogFactory.getLog(AnnotationConfigContextLoaderUtils.class); - private AnnotationConfigContextLoaderUtils() { - /* no-op */ - } - - private static boolean isStaticNonPrivateAndNonFinal(Class clazz) { - Assert.notNull(clazz, "Class must not be null"); - int modifiers = clazz.getModifiers(); - return (Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers) && !Modifier.isFinal(modifiers)); - } - - /** - * Determine if the supplied {@link Class} meets the criteria for being - * considered a default configuration class candidate. - * - *

Specifically, such candidates: - * - *

    - *
  • must not be {@code null}
  • - *
  • must not be {@code private}
  • - *
  • must not be {@code final}
  • - *
  • must be {@code static}
  • - *
  • must be annotated with {@code @Configuration}
  • - *
- * - * @param clazz the class to check - * @return {@code true} if the supplied class meets the candidate criteria - */ - private static boolean isDefaultConfigurationClassCandidate(Class clazz) { - return clazz != null && isStaticNonPrivateAndNonFinal(clazz) && clazz.isAnnotationPresent(Configuration.class); - } - /** * Detect the default configuration classes for the supplied test class. - * *

The returned class array will contain all static inner classes of * the supplied class that meet the requirements for {@code @Configuration} * class implementations as specified in the documentation for * {@link Configuration @Configuration}. - * *

The implementation of this method adheres to the contract defined in the * {@link org.springframework.test.context.SmartContextLoader SmartContextLoader} * SPI. Specifically, this method uses introspection to detect default @@ -96,7 +64,8 @@ public abstract class AnnotationConfigContextLoaderUtils { for (Class candidate : declaringClass.getDeclaredClasses()) { if (isDefaultConfigurationClassCandidate(candidate)) { configClasses.add(candidate); - } else { + } + else { if (logger.isDebugEnabled()) { logger.debug(String.format( "Ignoring class [%s]; it must be static, non-private, non-final, and annotated " @@ -117,4 +86,28 @@ public abstract class AnnotationConfigContextLoaderUtils { return configClasses.toArray(new Class[configClasses.size()]); } + /** + * Determine if the supplied {@link Class} meets the criteria for being + * considered a default configuration class candidate. + *

Specifically, such candidates: + *

    + *
  • must not be {@code null}
  • + *
  • must not be {@code private}
  • + *
  • must not be {@code final}
  • + *
  • must be {@code static}
  • + *
  • must be annotated with {@code @Configuration}
  • + *
+ * @param clazz the class to check + * @return {@code true} if the supplied class meets the candidate criteria + */ + private static boolean isDefaultConfigurationClassCandidate(Class clazz) { + return (clazz != null && isStaticNonPrivateAndNonFinal(clazz) && clazz.isAnnotationPresent(Configuration.class)); + } + + private static boolean isStaticNonPrivateAndNonFinal(Class clazz) { + Assert.notNull(clazz, "Class must not be null"); + int modifiers = clazz.getModifiers(); + return (Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers) && !Modifier.isFinal(modifiers)); + } + } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java index e92b8c7d7ff..f1bde2359cb 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java @@ -78,7 +78,7 @@ public abstract class AbstractMockMvcBuilder public final T addFilters(Filter... filters) { Assert.notNull(filters, "filters cannot be null"); - for(Filter f : filters) { + for (Filter f : filters) { Assert.notNull(f, "filters cannot contain null values"); this.filters.add(f); } @@ -112,7 +112,7 @@ public abstract class AbstractMockMvcBuilder Assert.notNull(filter, "filter cannot be null"); Assert.notNull(urlPatterns, "urlPatterns cannot be null"); - if(urlPatterns.length > 0) { + if (urlPatterns.length > 0) { filter = new PatternMappingFilterProxy(filter, urlPatterns); } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/PatternMappingFilterProxy.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/PatternMappingFilterProxy.java index 29e2845be31..fb0e553c566 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/PatternMappingFilterProxy.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/PatternMappingFilterProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * 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 @@ -10,12 +10,12 @@ * 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 org.springframework.test.web.servlet.setup; import java.io.IOException; import java.util.ArrayList; import java.util.List; - import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -61,29 +61,32 @@ final class PatternMappingFilterProxy implements Filter { public PatternMappingFilterProxy(Filter delegate, String... urlPatterns) { Assert.notNull(delegate, "A delegate Filter is required"); this.delegate = delegate; - for(String urlPattern : urlPatterns) { + for (String urlPattern : urlPatterns) { addUrlPattern(urlPattern); } } private void addUrlPattern(String urlPattern) { Assert.notNull(urlPattern, "Found null URL Pattern"); - if(urlPattern.startsWith(EXTENSION_MAPPING_PATTERN)) { + if (urlPattern.startsWith(EXTENSION_MAPPING_PATTERN)) { this.endsWithMatches.add(urlPattern.substring(1, urlPattern.length())); - } else if(urlPattern.equals(PATH_MAPPING_PATTERN)) { + } + else if (urlPattern.equals(PATH_MAPPING_PATTERN)) { this.startsWithMatches.add(""); } else if (urlPattern.endsWith(PATH_MAPPING_PATTERN)) { this.startsWithMatches.add(urlPattern.substring(0, urlPattern.length() - 1)); this.exactMatches.add(urlPattern.substring(0, urlPattern.length() - 2)); - } else { - if("".equals(urlPattern)) { + } + else { + if ("".equals(urlPattern)) { urlPattern = "/"; } this.exactMatches.add(urlPattern); } } + @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { @@ -91,29 +94,30 @@ final class PatternMappingFilterProxy implements Filter { HttpServletRequest httpRequest = (HttpServletRequest) request; String requestPath = urlPathHelper.getPathWithinApplication(httpRequest); - if(matches(requestPath)) { + if (matches(requestPath)) { this.delegate.doFilter(request, response, filterChain); - } else { + } + else { filterChain.doFilter(request, response); } } private boolean matches(String requestPath) { - for(String pattern : this.exactMatches) { - if(pattern.equals(requestPath)) { + for (String pattern : this.exactMatches) { + if (pattern.equals(requestPath)) { return true; } } - if(!requestPath.startsWith("/")) { + if (!requestPath.startsWith("/")) { return false; } - for(String pattern : this.endsWithMatches) { - if(requestPath.endsWith(pattern)) { + for (String pattern : this.endsWithMatches) { + if (requestPath.endsWith(pattern)) { return true; } } - for(String pattern : this.startsWithMatches) { - if(requestPath.startsWith(pattern)) { + for (String pattern : this.startsWithMatches) { + if (requestPath.startsWith(pattern)) { return true; } } diff --git a/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingClientHttpRequest.java index d15037ccd02..58841e2278a 100644 --- a/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/SimpleStreamingClientHttpRequest.java @@ -72,7 +72,7 @@ final class SimpleStreamingClientHttpRequest extends AbstractClientHttpRequest { @Override protected OutputStream getBodyInternal(HttpHeaders headers) throws IOException { if (this.body == null) { - if(this.outputStreaming) { + if (this.outputStreaming) { int contentLength = (int) headers.getContentLength(); if (contentLength >= 0) { this.connection.setFixedLengthStreamingMode(contentLength); diff --git a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java index 386ca52e36e..09d3ec1cf31 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java @@ -138,7 +138,7 @@ public class ResourceHttpMessageConverter extends AbstractHttpMessageConverter e WireFeedInput feedInput = new WireFeedInput(); MediaType contentType = inputMessage.getHeaders().getContentType(); - Charset charset; - if (contentType != null && contentType.getCharSet() != null) { - charset = contentType.getCharSet(); - } else { - charset = DEFAULT_CHARSET; - } + Charset charset = + (contentType != null && contentType.getCharSet() != null? contentType.getCharSet() : DEFAULT_CHARSET); try { Reader reader = new InputStreamReader(inputMessage.getBody(), charset); return (T) feedInput.build(reader); diff --git a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java index 689f55ae8c9..657c77c838c 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java @@ -201,7 +201,8 @@ public class ContentNegotiationManagerFactoryBean PathExtensionContentNegotiationStrategy strategy; if (this.servletContext != null) { strategy = new ServletPathExtensionContentNegotiationStrategy(this.servletContext, this.mediaTypes); - } else { + } + else { strategy = new PathExtensionContentNegotiationStrategy(this.mediaTypes); } strategy.setIgnoreUnknownExtensions(this.ignoreUnknownPathExtensions); diff --git a/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java b/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java index 164c77ff415..1b88177cc2b 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java +++ b/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java @@ -116,7 +116,7 @@ public class WebRequestDataBinder extends WebDataBinder { public void bind(WebRequest request) { MutablePropertyValues mpvs = new MutablePropertyValues(request.getParameterMap()); - if(isMultipartRequest(request) && (request instanceof NativeWebRequest)) { + if (isMultipartRequest(request) && (request instanceof NativeWebRequest)) { MultipartRequest multipartRequest = ((NativeWebRequest) request).getNativeRequest(MultipartRequest.class); if (multipartRequest != null) { bindMultipart(multipartRequest.getMultiFileMap(), mpvs); diff --git a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java index a3a86e92b13..a22175ef6b3 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java @@ -799,7 +799,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat public ResponseEntityResponseExtractor(Type responseType) { if (responseType != null && !Void.class.equals(responseType)) { this.delegate = new HttpMessageConverterExtractor(responseType, getMessageConverters(), logger); - } else { + } + else { this.delegate = null; } } diff --git a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextAwareProcessor.java b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextAwareProcessor.java index dfbc21530f6..b20a79fe73f 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextAwareProcessor.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextAwareProcessor.java @@ -82,7 +82,7 @@ public class ServletContextAwareProcessor implements BeanPostProcessor { * has been registered. */ protected ServletContext getServletContext() { - if(this.servletContext == null && getServletConfig() != null) { + if (this.servletContext == null && getServletConfig() != null) { return getServletConfig().getServletContext(); } return this.servletContext; diff --git a/spring-web/src/main/java/org/springframework/web/filter/CompositeFilter.java b/spring-web/src/main/java/org/springframework/web/filter/CompositeFilter.java index 37e9c015ff1..43db6b06efc 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/CompositeFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/CompositeFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ package org.springframework.web.filter; import java.io.IOException; import java.util.ArrayList; import java.util.List; - import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -28,85 +27,91 @@ import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; /** - * A generic composite servlet {@link Filter} that just delegates its behaviour to a chain (list) of user supplied - * filters, achieving the functionality of a {@link FilterChain}, but conveniently using only {@link Filter} instances. - * This is useful for filters that require dependency injection, and can therefore be set up in a Spring application - * context. Typically this composite would be used in conjunction with {@link DelegatingFilterProxy}, so that it can be - * declared in Spring but applied to a servlet context. + * A generic composite servlet {@link Filter} that just delegates its behavior + * to a chain (list) of user-supplied filters, achieving the functionality of a + * {@link FilterChain}, but conveniently using only {@link Filter} instances. * - * @since 3.1 + *

This is useful for filters that require dependency injection, and can + * therefore be set up in a Spring application context. Typically, this + * composite would be used in conjunction with {@link DelegatingFilterProxy}, + * so that it can be declared in Spring but applied to a servlet context. * * @author Dave Syer - * + * @since 3.1 */ public class CompositeFilter implements Filter { private List filters = new ArrayList(); + public void setFilters(List filters) { this.filters = new ArrayList(filters); } - /** - * Clean up all the filters supplied, calling each one's destroy method in turn, but in reverse order. - * - * @see Filter#init(FilterConfig) - */ - @Override - public void destroy() { - for (int i = filters.size(); i-- > 0;) { - Filter filter = filters.get(i); - filter.destroy(); - } - } /** * Initialize all the filters, calling each one's init method in turn in the order supplied. - * * @see Filter#init(FilterConfig) */ @Override public void init(FilterConfig config) throws ServletException { - for (Filter filter : filters) { + for (Filter filter : this.filters) { filter.init(config); } } /** - * Forms a temporary chain from the list of delegate filters supplied ({@link #setFilters(List)}) and executes them - * in order. Each filter delegates to the next one in the list, achieving the normal behaviour of a - * {@link FilterChain}, despite the fact that this is a {@link Filter}. - * + * Forms a temporary chain from the list of delegate filters supplied ({@link #setFilters}) + * and executes them in order. Each filter delegates to the next one in the list, achieving + * the normal behavior of a {@link FilterChain}, despite the fact that this is a {@link Filter}. * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) */ @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, - ServletException { - new VirtualFilterChain(chain, filters).doFilter(request, response); + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + + new VirtualFilterChain(chain, this.filters).doFilter(request, response); + } + + /** + * Clean up all the filters supplied, calling each one's destroy method in turn, but in reverse order. + * @see Filter#init(FilterConfig) + */ + @Override + public void destroy() { + for (int i = this.filters.size(); i-- > 0;) { + Filter filter = this.filters.get(i); + filter.destroy(); + } } + private static class VirtualFilterChain implements FilterChain { + private final FilterChain originalChain; + private final List additionalFilters; + private int currentPosition = 0; - private VirtualFilterChain(FilterChain chain, List additionalFilters) { + public VirtualFilterChain(FilterChain chain, List additionalFilters) { this.originalChain = chain; this.additionalFilters = additionalFilters; } @Override - public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, - ServletException { - if (currentPosition == additionalFilters.size()) { - originalChain.doFilter(request, response); - } else { - currentPosition++; - Filter nextFilter = additionalFilters.get(currentPosition - 1); + public void doFilter(final ServletRequest request, final ServletResponse response) + throws IOException, ServletException { + + if (this.currentPosition == this.additionalFilters.size()) { + this.originalChain.doFilter(request, response); + } + else { + this.currentPosition++; + Filter nextFilter = this.additionalFilters.get(this.currentPosition - 1); nextFilter.doFilter(request, response, this); } } - } } diff --git a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java index c0aa26eb127..9a2bedea88b 100644 --- a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java +++ b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java @@ -143,23 +143,23 @@ public class ControllerAdviceBean implements Ordered { * @since 4.0 */ public boolean isApplicableToBeanType(Class beanType) { - if(!hasSelectors()) { + if (!hasSelectors()) { return true; } else if (beanType != null) { for (Class clazz : this.assignableTypes) { - if(ClassUtils.isAssignable(clazz, beanType)) { + if (ClassUtils.isAssignable(clazz, beanType)) { return true; } } for (Class annotationClass : this.annotations) { - if(AnnotationUtils.findAnnotation(beanType, annotationClass) != null) { + if (AnnotationUtils.findAnnotation(beanType, annotationClass) != null) { return true; } } String packageName = beanType.getPackage().getName(); for (Package basePackage : this.basePackages) { - if(packageName.startsWith(basePackage.getName())) { + if (packageName.startsWith(basePackage.getName())) { return true; } } @@ -226,7 +226,7 @@ public class ControllerAdviceBean implements Ordered { for (String pkgName : basePackageNames) { if (StringUtils.hasText(pkgName)) { Package pkg = Package.getPackage(pkgName); - if(pkg != null) { + if (pkg != null) { basePackages.add(pkg); } else { diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java index 19c170c9d6b..46af047ad83 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java @@ -148,7 +148,7 @@ public class ExceptionHandlerMethodResolver { */ private Method getMappedMethod(Class exceptionType) { List> matches = new ArrayList>(); - for(Class mappedException : this.mappedMethods.keySet()) { + for (Class mappedException : this.mappedMethods.keySet()) { if (mappedException.isAssignableFrom(exceptionType)) { matches.add(mappedException); } diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.java index f881b095e48..2a067046e71 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.java @@ -176,7 +176,7 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod Assert.notNull(multipartRequest, "Expected MultipartHttpServletRequest: is a MultipartResolver configured?"); arg = multipartRequest.getFiles(name); } - else if(isMultipartFileArray(parameter)) { + else if (isMultipartFileArray(parameter)) { assertIsMultipartRequest(servletRequest); Assert.notNull(multipartRequest, "Expected MultipartHttpServletRequest: is a MultipartResolver configured?"); arg = multipartRequest.getFiles(name).toArray(new MultipartFile[0]); diff --git a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java index 1355a991cf8..4e9d4b1bdfb 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java @@ -396,7 +396,7 @@ final class HierarchicalUriComponents extends UriComponents { String path = getPath(); if (StringUtils.hasLength(path) && path.charAt(0) != PATH_DELIMITER) { // Only prefix the path delimiter if something exists before it - if(getScheme() != null || getUserInfo() != null || getHost() != null || getPort() != -1) { + if (getScheme() != null || getUserInfo() != null || getHost() != null || getPort() != -1) { path = PATH_DELIMITER + path; } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java index deb753e70b1..168b59347b8 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java @@ -366,7 +366,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { private void configurePathMatchingProperties(RootBeanDefinition handlerMappingDef, Element element, ParserContext parserContext) { Element pathMatchingElement = DomUtils.getChildElementByTagName(element, "path-matching"); - if(pathMatchingElement != null) { + if (pathMatchingElement != null) { Object source = parserContext.extractSource(element); if (pathMatchingElement.hasAttribute("suffix-pattern")) { Boolean useSuffixPatternMatch = Boolean.valueOf(pathMatchingElement.getAttribute("suffix-pattern")); @@ -568,7 +568,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { if (StringUtils.hasText("bean")) { reference = new RuntimeBeanReference(refElement.getAttribute("bean"),false); list.add(reference); - }else if(StringUtils.hasText("parent")){ + }else if (StringUtils.hasText("parent")){ reference = new RuntimeBeanReference(refElement.getAttribute("parent"),true); list.add(reference); }else{ diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java index 2e62d944234..30e1688d4a0 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java @@ -63,8 +63,8 @@ abstract class MvcNamespaceUtils { * @return a RuntimeBeanReference to this {@link UrlPathHelper} instance */ public static RuntimeBeanReference registerUrlPathHelper(RuntimeBeanReference urlPathHelperRef, ParserContext parserContext, Object source) { - if(urlPathHelperRef != null) { - if(parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)) { + if (urlPathHelperRef != null) { + if (parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)) { parserContext.getRegistry().removeAlias(URL_PATH_HELPER_BEAN_NAME); } parserContext.getRegistry().registerAlias(urlPathHelperRef.getBeanName(), URL_PATH_HELPER_BEAN_NAME); @@ -86,8 +86,8 @@ abstract class MvcNamespaceUtils { * @return a RuntimeBeanReference to this {@link PathMatcher} instance */ public static RuntimeBeanReference registerPathMatcher(RuntimeBeanReference pathMatcherRef, ParserContext parserContext, Object source) { - if(pathMatcherRef != null) { - if(parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) { + if (pathMatcherRef != null) { + if (parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) { parserContext.getRegistry().removeAlias(PATH_MATCHER_BEAN_NAME); } parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java index acfe52e0ee8..a916651afb0 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java @@ -110,12 +110,12 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser { } ManagedList resourceResolvers = parseResourceResolvers(parserContext, element, source); - if(!resourceResolvers.isEmpty()) { + if (!resourceResolvers.isEmpty()) { resourceHandlerDef.getPropertyValues().add("resourceResolvers", resourceResolvers); } ManagedList resourceTransformers = parseResourceTransformers(parserContext, element, source); - if(!resourceTransformers.isEmpty()) { + if (!resourceTransformers.isEmpty()) { resourceHandlerDef.getPropertyValues().add("resourceTransformers", resourceTransformers); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java index a4486b3207c..25cf2ae3761 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java @@ -175,7 +175,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser { List elements = DomUtils.getChildElementsByTagName(resolverElement, new String[] {"default-views"}); if (!elements.isEmpty()) { ManagedList list = new ManagedList(); - for(Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) { + for (Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) { list.add(context.getDelegate().parsePropertySubElement(element, null)); } values.add("defaultViews", list); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java index 084250ae49e..1a53e9bb884 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java @@ -218,19 +218,19 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv handlerMapping.setContentNegotiationManager(mvcContentNegotiationManager()); PathMatchConfigurer configurer = getPathMatchConfigurer(); - if(configurer.isUseSuffixPatternMatch() != null) { + if (configurer.isUseSuffixPatternMatch() != null) { handlerMapping.setUseSuffixPatternMatch(configurer.isUseSuffixPatternMatch()); } - if(configurer.isUseRegisteredSuffixPatternMatch() != null) { + if (configurer.isUseRegisteredSuffixPatternMatch() != null) { handlerMapping.setUseRegisteredSuffixPatternMatch(configurer.isUseRegisteredSuffixPatternMatch()); } - if(configurer.isUseTrailingSlashMatch() != null) { + if (configurer.isUseTrailingSlashMatch() != null) { handlerMapping.setUseTrailingSlashMatch(configurer.isUseTrailingSlashMatch()); } - if(configurer.getPathMatcher() != null) { + if (configurer.getPathMatcher() != null) { handlerMapping.setPathMatcher(configurer.getPathMatcher()); } - if(configurer.getUrlPathHelper() != null) { + if (configurer.getUrlPathHelper() != null) { handlerMapping.setUrlPathHelper(configurer.getUrlPathHelper()); } return handlerMapping; @@ -534,7 +534,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv */ @Bean public PathMatcher mvcPathMatcher() { - if(getPathMatchConfigurer().getPathMatcher() != null) { + if (getPathMatchConfigurer().getPathMatcher() != null) { return getPathMatchConfigurer().getPathMatcher(); } else { @@ -551,7 +551,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv */ @Bean public UrlPathHelper mvcUrlPathHelper() { - if(getPathMatchConfigurer().getUrlPathHelper() != null) { + if (getPathMatchConfigurer().getUrlPathHelper() != null) { return getPathMatchConfigurer().getUrlPathHelper(); } else { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ProducesRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ProducesRequestCondition.java index 684d2390915..c51f16fbe77 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ProducesRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ProducesRequestCondition.java @@ -103,7 +103,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition entry : this.exceptionHandlerAdviceCache.entrySet()) { - if(entry.getKey().isApplicableToBeanType(handlerType)) { + if (entry.getKey().isApplicableToBeanType(handlerType)) { ExceptionHandlerMethodResolver resolver = entry.getValue(); Method method = resolver.resolveMethod(exception); if (method != null) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransfomer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransfomer.java index e995aa42c25..52844206625 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransfomer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransfomer.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.resource; import java.io.ByteArrayOutputStream; @@ -69,6 +70,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer { private final String fileExtension; + /** * Create an AppCacheResourceTransformer that transforms files with extension ".manifest" */ @@ -90,6 +92,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer { this.sectionTransformers.put("CACHE:", new CacheSection()); } + @Override public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) throws IOException { resource = transformerChain.transform(request, resource); @@ -102,7 +105,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer { byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream()); String content = new String(bytes, DEFAULT_CHARSET); - if(!content.startsWith(MANIFEST_HEADER)) { + if (!content.startsWith(MANIFEST_HEADER)) { if (logger.isTraceEnabled()) { logger.trace("AppCache manifest does not start with 'CACHE MANIFEST', skipping: " + resource); } @@ -118,17 +121,14 @@ public class AppCacheManifestTransfomer implements ResourceTransformer { Scanner scanner = new Scanner(content); SectionTransformer currentTransformer = this.sectionTransformers.get(MANIFEST_HEADER); - while(scanner.hasNextLine()) { + while (scanner.hasNextLine()) { String line = scanner.nextLine(); - - if(this.sectionTransformers.containsKey(line.trim())) { + if (this.sectionTransformers.containsKey(line.trim())) { currentTransformer = this.sectionTransformers.get(line.trim()); contentWriter.write(line + "\n"); hashBuilder.appendString(line); } else { - - contentWriter.write(currentTransformer.transform(line, hashBuilder, resource, transformerChain) + "\n"); } } @@ -147,23 +147,25 @@ public class AppCacheManifestTransfomer implements ResourceTransformer { /** * Transforms a line in a section of the manifest - * - * The actual transformation depends on the chose transformation strategy + *

The actual transformation depends on the chose transformation strategy * for the current manifest section (CACHE, NETWORK, FALLBACK, etc). */ String transform(String line, HashBuilder builder, Resource resource, ResourceTransformerChain transformerChain) throws IOException; } + private static class NoOpSection implements SectionTransformer { - public String transform(String line, HashBuilder builder, - Resource resource, ResourceTransformerChain transformerChain) throws IOException { + public String transform(String line, HashBuilder builder, Resource resource, ResourceTransformerChain transformerChain) + throws IOException { + builder.appendString(line); return line; } } + private static class CacheSection implements SectionTransformer { private final String COMMENT_DIRECTIVE = "#"; @@ -172,30 +174,26 @@ public class AppCacheManifestTransfomer implements ResourceTransformer { public String transform(String line, HashBuilder builder, Resource resource, ResourceTransformerChain transformerChain) throws IOException { - if(isLink(line) && !hasScheme(line)) { - + if (isLink(line) && !hasScheme(line)) { Resource appCacheResource = transformerChain.getResolverChain().resolveResource(null, line, Arrays.asList(resource)); String path = transformerChain.getResolverChain().resolveUrlPath(line, Arrays.asList(resource)); - builder.appendResource(appCacheResource); if (logger.isTraceEnabled()) { logger.trace("Link modified: " + path + " (original: " + line + ")"); } - return path; } - builder.appendString(line); return line; } private boolean hasScheme(String link) { int schemeIndex = link.indexOf(":"); - return link.startsWith("//") || (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/")); + return (link.startsWith("//") || (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/"))); } private boolean isLink(String line) { - return StringUtils.hasText(line) && !line.startsWith(COMMENT_DIRECTIVE); + return (StringUtils.hasText(line) && !line.startsWith(COMMENT_DIRECTIVE)); } } @@ -204,7 +202,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer { private final ByteArrayOutputStream baos; - private HashBuilder(int initialSize) { + public HashBuilder(int initialSize) { this.baos = new ByteArrayOutputStream(initialSize); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java index 2dac50810d3..83be432b6d2 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java @@ -102,7 +102,7 @@ public class CssLinkResourceTransformer implements ResourceTransformer { writer.write(content.substring(index, info.getStart())); String link = content.substring(info.getStart(), info.getEnd()); String newLink = null; - if(!hasScheme(link)) { + if (!hasScheme(link)) { newLink = transformerChain.getResolverChain().resolveUrlPath(link, Arrays.asList(resource)); } if (logger.isTraceEnabled()) { @@ -159,7 +159,8 @@ public class CssLinkResourceTransformer implements ResourceTransformer { index = extractLink(index, content, linkInfos); } - } while (true); + } + while (true); } private int skipWhitespace(String content, int index) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java index 212ef71278a..0e195f615f1 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java @@ -73,7 +73,7 @@ public class VersionResourceResolver extends AbstractResourceResolver { } VersionStrategy versionStrategy = findStrategy(requestPath); - if(versionStrategy == null) { + if (versionStrategy == null) { return null; } @@ -114,7 +114,7 @@ public class VersionResourceResolver extends AbstractResourceResolver { String baseUrl = chain.resolveUrlPath(resourceUrlPath, locations); if (StringUtils.hasText(baseUrl)) { VersionStrategy versionStrategy = findStrategy(resourceUrlPath); - if(versionStrategy == null) { + if (versionStrategy == null) { return null; } return versionStrategy.addVersionToUrl(baseUrl, locations, chain); @@ -129,12 +129,12 @@ public class VersionResourceResolver extends AbstractResourceResolver { protected VersionStrategy findStrategy(String requestPath) { String path = "/".concat(requestPath); List matchingPatterns = new ArrayList(); - for(String pattern : this.versionStrategyMap.keySet()) { - if(this.pathMatcher.match(pattern, path)) { + for (String pattern : this.versionStrategyMap.keySet()) { + if (this.pathMatcher.match(pattern, path)) { matchingPatterns.add(pattern); } } - if(!matchingPatterns.isEmpty()) { + if (!matchingPatterns.isEmpty()) { Comparator comparator = this.pathMatcher.getPatternComparator(path); Collections.sort(matchingPatterns, comparator); return this.versionStrategyMap.get(matchingPatterns.get(0)); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/MessageTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/MessageTag.java index 1ff54e05aaf..f513af29d5b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/MessageTag.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/MessageTag.java @@ -228,7 +228,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware { if (this.code != null || this.text != null) { // We have a code or default text that we need to resolve. Object[] argumentsArray = resolveArguments(this.arguments); - if(!this.nestedArguments.isEmpty()) { + if (!this.nestedArguments.isEmpty()) { argumentsArray = appendArguments(argumentsArray, this.nestedArguments.toArray()); } @@ -250,7 +250,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware { } private Object[] appendArguments(Object[] sourceArguments, Object[] additionalArguments) { - if(ObjectUtils.isEmpty(sourceArguments)) { + if (ObjectUtils.isEmpty(sourceArguments)) { return additionalArguments; } Object[] arguments = new Object[sourceArguments.length + additionalArguments.length]; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/OptionsTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/OptionsTag.java index 09b7e8f0001..518722fdd29 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/OptionsTag.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/OptionsTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -137,7 +137,8 @@ public class OptionsTag extends AbstractHtmlElementTag { Object itemsObject = null; if (items != null) { itemsObject = (items instanceof String ? evaluate("items", items) : items); - } else { + } + else { Class selectTagBoundType = selectTag.getBindStatus().getValueType(); if (selectTagBoundType != null && selectTagBoundType.isEnum()) { itemsObject = selectTagBoundType.getEnumConstants(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/PasswordInputTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/PasswordInputTag.java index 02b5b9b7a8a..5400abe27ec 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/PasswordInputTag.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/PasswordInputTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,20 +35,21 @@ public class PasswordInputTag extends InputTag { /** * Is the password value to be rendered? - * @return {@code true} if the password value to be rendered. + * @param showPassword {@code true} if the password value is to be rendered */ - public boolean isShowPassword() { - return this.showPassword; + public void setShowPassword(boolean showPassword) { + this.showPassword = showPassword; } /** * Is the password value to be rendered? - * @param showPassword {@code true} if the password value is to be rendered. + * @return {@code true} if the password value to be rendered */ - public void setShowPassword(boolean showPassword) { - this.showPassword = showPassword; + public boolean isShowPassword() { + return this.showPassword; } + /** * Flags "type" as an illegal dynamic attribute. */ @@ -75,8 +76,10 @@ public class PasswordInputTag extends InputTag { protected void writeValue(TagWriter tagWriter) throws JspException { if (this.showPassword) { super.writeValue(tagWriter); - } else { + } + else { tagWriter.writeAttribute("value", processFieldValue(getName(), "", getType())); } } + } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java index b2da237bafa..557d26777e2 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java @@ -283,7 +283,7 @@ public class MappingJackson2JsonView extends AbstractView { Class serializationView = (Class) model.get(JsonView.class.getName()); String jsonpParameterValue = getJsonpParameterValue(request); Object value = filterModel(model); - if(serializationView != null || jsonpParameterValue != null) { + if (serializationView != null || jsonpParameterValue != null) { MappingJacksonValue container = new MappingJacksonValue(value); container.setSerializationView(serializationView); container.setJsonpFunction(jsonpParameterValue); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/spring.vm b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/spring.vm index 9c1af588413..159b145117f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/spring.vm +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/velocity/spring.vm @@ -82,7 +82,7 @@ * by user config. *# #macro( springBind $path ) - #if("$!springHtmlEscape" != "") + #if ("$!springHtmlEscape" != "") #set( $status = $springMacroRequestContext.getBindStatus($path, $springHtmlEscape) ) #else #set( $status = $springMacroRequestContext.getBindStatus($path) ) @@ -171,7 +171,7 @@ * from a list of options. * * The null check for $status.value leverages Velocity's 'quiet' notation rather - * than the more common #if($status.value) since this method evaluates to the + * than the more common #if ($status.value) since this method evaluates to the * boolean 'false' if the content of $status.value is the String "false" - not * what we want. * @@ -185,7 +185,7 @@ @@ -208,7 +208,7 @@ #foreach($option in $options.keySet()) #end @@ -231,7 +231,7 @@ #springBind($path) #foreach($option in $options.keySet()) - + #end #** @@ -293,10 +293,10 @@ *# #macro( springShowErrors $separator $classOrStyle ) #foreach($error in $status.errorMessages) - #if($classOrStyle == "") + #if ($classOrStyle == "") ${error} #else - #if($classOrStyle.indexOf(":") == -1) + #if ($classOrStyle.indexOf(":") == -1) #set($attr="class") #else #set($attr="style") @@ -314,7 +314,7 @@ * depending on the value of a 'springXhtmlCompliant' variable in the * template context. *# -#macro( springCloseTag )#if($springXhtmlCompliant)/>#else>#end #end +#macro( springCloseTag )#if ($springXhtmlCompliant)/>#else>#end #end diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java index 67c534a9546..862de0a3827 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java @@ -107,7 +107,7 @@ public class WebSocketExtension { } else { List result = new ArrayList(); - for(String token : extensions.split(",")) { + for (String token : extensions.split(",")) { result.add(parseExtension(token)); } return result; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketHttpHeaders.java b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketHttpHeaders.java index 27aa8030bd1..c21fd301e1e 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketHttpHeaders.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketHttpHeaders.java @@ -122,7 +122,7 @@ public class WebSocketHttpHeaders extends HttpHeaders { */ public void setSecWebSocketExtensions(List extensions) { List result = new ArrayList(extensions.size()); - for(WebSocketExtension extension : extensions) { + for (WebSocketExtension extension : extensions) { result.add(extension.toString()); } set(SEC_WEBSOCKET_EXTENSIONS, toCommaDelimitedString(result)); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java index cf76a001ab8..1ce3fdd2be5 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java @@ -173,8 +173,8 @@ public class JettyWebSocketSession extends AbstractWebSocketSession { List source = getNativeSession().getUpgradeResponse().getExtensions(); this.extensions = new ArrayList(source.size()); - for(ExtensionConfig e : source) { - this.extensions.add(new WebSocketExtension(e.getName(), e.getParameters())); + for (ExtensionConfig ec : source) { + this.extensions.add(new WebSocketExtension(ec.getName(), ec.getParameters())); } if (this.user == null) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSession.java index 2ddfec02ce3..95d30f9122d 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSession.java @@ -184,11 +184,11 @@ public class StandardWebSocketSession extends AbstractWebSocketSession List source = getNativeSession().getNegotiatedExtensions(); this.extensions = new ArrayList(source.size()); - for(Extension e : source) { - this.extensions.add(new StandardToWebSocketExtensionAdapter(e)); + for (Extension ext : source) { + this.extensions.add(new StandardToWebSocketExtensionAdapter(ext)); } - if(this.user == null) { + if (this.user == null) { this.user = session.getUserPrincipal(); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/HandlersBeanDefinitionParser.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/HandlersBeanDefinitionParser.java index 4b973ee0a99..e187beeb739 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/HandlersBeanDefinitionParser.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/HandlersBeanDefinitionParser.java @@ -85,7 +85,7 @@ class HandlersBeanDefinitionParser implements BeanDefinitionParser { ManagedMap urlMap = new ManagedMap(); urlMap.setSource(source); - for(Element mappingElement : DomUtils.getChildElementsByTagName(element, "mapping")) { + for (Element mappingElement : DomUtils.getChildElementsByTagName(element, "mapping")) { strategy.addMapping(mappingElement, urlMap, context); } handlerMappingDef.getPropertyValues().add("urlMap", urlMap); @@ -122,7 +122,7 @@ class HandlersBeanDefinitionParser implements BeanDefinitionParser { ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addIndexedArgumentValue(0, handlerReference); - if(this.handshakeHandlerReference != null) { + if (this.handshakeHandlerReference != null) { cavs.addIndexedArgumentValue(1, this.handshakeHandlerReference); } RootBeanDefinition requestHandlerDef = new RootBeanDefinition(WebSocketHttpRequestHandler.class, cavs, null); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java index 4785d161091..0b9c04da22c 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java @@ -132,7 +132,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { String pathAttribute = endpointElem.getAttribute("path"); Assert.state(StringUtils.hasText(pathAttribute), "Invalid (no path mapping)"); List paths = Arrays.asList(StringUtils.tokenizeToStringArray(pathAttribute, ",")); - for(String path : paths) { + for (String path : paths) { path = path.trim(); Assert.state(StringUtils.hasText(path), "Invalid path attribute: " + pathAttribute); if (DomUtils.getChildElementByTagName(endpointElem, "sockjs") != null) { @@ -374,7 +374,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addIndexedArgumentValue(0, brokerChannel); RootBeanDefinition beanDef = new RootBeanDefinition(SimpMessagingTemplate.class,cavs, null); - if(element.hasAttribute("user-destination-prefix")) { + if (element.hasAttribute("user-destination-prefix")) { beanDef.getPropertyValues().add("userDestinationPrefix", element.getAttribute("user-destination-prefix")); } beanDef.getPropertyValues().add("messageConverter", messageConverter); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java index b3e4b041c23..714b2957e88 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java @@ -123,7 +123,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy { private List getWebSocketExtensions() { List result = new ArrayList(); - for(String name : this.factory.getExtensionFactory().getExtensionNames()) { + for (String name : this.factory.getExtensionFactory().getExtensionNames()) { result.add(new WebSocketExtension(name)); } return result; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java index 763906f41a3..5d9382117c8 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public class HtmlFileTransportHandler extends AbstractHttpSendingTransportHandle " " ); - while(sb.length() < MINIMUM_PARTIAL_HTML_CONTENT_LENGTH) { + while (sb.length() < MINIMUM_PARTIAL_HTML_CONTENT_LENGTH) { sb.append(" "); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/StreamingSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/StreamingSockJsSession.java index 1e2d301dbe8..7f733e62c96 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/StreamingSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/StreamingSockJsSession.java @@ -72,9 +72,9 @@ public class StreamingSockJsSession extends AbstractHttpSockJsSession { this.byteCount = 0; break; } - } while (!getMessageCache().isEmpty()); + } + while (!getMessageCache().isEmpty()); scheduleHeartbeat(); } } -