From 6e95b2613e6e831319d96d7c0f0b54ef5036c3ea Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 24 Jul 2014 18:35:49 +0200 Subject: [PATCH] Polishing --- .../build/gradle/MergePlugin.groovy | 13 ++- .../TestSourceSetDependenciesPlugin.groovy | 7 +- .../aop/framework/JdkDynamicAopProxy.java | 6 +- .../CustomizableTraceInterceptor.java | 4 +- .../AbstractDependencyInjectionAspect.aj | 4 +- .../aspectj/AnnotationBeanConfigurerAspect.aj | 2 +- .../beans/BeanWrapperImpl.java | 3 +- .../beans/PropertyMatches.java | 5 +- .../beans/TypeConverterDelegate.java | 4 +- .../support/DefaultSingletonBeanRegistry.java | 10 +-- .../AbstractSimpleBeanDefinitionParser.java | 2 +- .../SimpleConstructorNamespaceHandler.java | 37 +++++---- .../propertyeditors/ResourceBundleEditor.java | 11 +-- .../quartz/SchedulerFactoryBean.java | 6 +- .../cache/config/CacheAdviceParser.java | 25 +++--- .../format/AnnotationFormatterFactory.java | 16 ++-- .../support/FormattingConversionService.java | 75 +++++++++-------- .../WebLogicClassPreProcessorAdapter.java | 35 ++++---- .../AnnotationJmxAttributeSource.java | 2 +- .../AbstractReflectiveMBeanInfoAssembler.java | 2 +- .../assembler/MetadataMBeanInfoAssembler.java | 8 +- .../DefaultMessageCodesResolver.java | 2 +- .../MethodValidationPostProcessor.java | 2 +- .../core/SerializableTypeWrapper.java | 2 +- .../core/convert/Property.java | 4 +- .../support/ArrayToArrayConverter.java | 14 ++-- .../support/ArrayToStringConverter.java | 7 +- .../convert/support/MapToMapConverter.java | 2 +- .../support/StringToCollectionConverter.java | 17 ++-- .../support/StringToEnumConverterFactory.java | 11 +-- .../support/StringToUUIDConverter.java | 2 +- .../core/io/AbstractResource.java | 4 +- .../org/springframework/util/ObjectUtils.java | 2 +- .../org/springframework/util/SocketUtils.java | 16 ++-- .../org/springframework/util/StopWatch.java | 8 +- .../util/comparator/InstanceComparator.java | 2 +- .../util/concurrent/FutureAdapter.java | 33 ++++---- .../InternalSpelExpressionParser.java | 41 ++++----- .../metadata/GenericCallMetaDataProvider.java | 8 +- .../GenericTableMetaDataProvider.java | 67 ++++++--------- .../connection/SingleConnectionFactory.java | 4 +- .../DefaultJmsActivationSpecFactory.java | 6 +- .../jms/support/JmsAccessor.java | 10 +-- ...bstractExceptionHandlerMethodResolver.java | 2 +- .../broker/AbstractBrokerMessageHandler.java | 40 +++++---- .../broker/DefaultSubscriptionRegistry.java | 4 +- .../AbstractMessageBrokerConfiguration.java | 2 +- .../config/StompBrokerRelayRegistration.java | 2 +- .../mock/web/MockHttpServletResponse.java | 4 +- .../AbstractDelegatingSmartContextLoader.java | 39 +++++---- .../AnnotationConfigContextLoaderUtils.java | 61 ++++++-------- .../servlet/setup/AbstractMockMvcBuilder.java | 4 +- .../setup/PatternMappingFilterProxy.java | 36 ++++---- .../SimpleStreamingClientHttpRequest.java | 2 +- .../AbstractWireFeedHttpMessageConverter.java | 8 +- .../json/Jackson2ObjectMapperFactoryBean.java | 2 +- .../ContentNegotiationManagerFactoryBean.java | 3 +- .../bind/support/WebRequestDataBinder.java | 2 +- .../web/client/RestTemplate.java | 3 +- .../support/ServletContextAwareProcessor.java | 2 +- .../web/filter/CompositeFilter.java | 83 ++++++++++--------- .../web/method/ControllerAdviceBean.java | 10 +-- .../ExceptionHandlerMethodResolver.java | 2 +- .../RequestParamMethodArgumentResolver.java | 2 +- .../web/util/HierarchicalUriComponents.java | 2 +- .../condition/ProducesRequestCondition.java | 2 +- .../RequestMethodsRequestCondition.java | 2 +- .../ExceptionHandlerExceptionResolver.java | 2 +- .../web/servlet/tags/MessageTag.java | 4 +- .../web/servlet/tags/form/OptionsTag.java | 5 +- .../servlet/tags/form/PasswordInputTag.java | 23 ++--- .../servlet/view/tiles2/TilesConfigurer.java | 2 +- .../web/servlet/view/velocity/spring.vm | 20 ++--- .../web/socket/WebSocketExtension.java | 2 +- .../web/socket/WebSocketHttpHeaders.java | 2 +- .../jetty/JettyRequestUpgradeStrategy.java | 2 +- .../handler/HtmlFileTransportHandler.java | 4 +- .../session/StreamingSockJsSession.java | 4 +- 78 files changed, 467 insertions(+), 463 deletions(-) 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 ab4a0d3cda..b2807d164e 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 1d6134ab59..8d252ffb79 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 68a621419f..e93aa9e5cb 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 5801d40550..f8b19cb71f 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 fa8fc6441f..58bebb9176 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 2f1e91ccd2..eea0835bd0 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-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java index d59e89a42c..c13a5868dc 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java @@ -398,7 +398,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/PropertyMatches.java b/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java index e69b09b71a..ea860ec161 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 d8b3eda2fd..d798eb3853 100644 --- a/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java @@ -296,12 +296,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/DefaultSingletonBeanRegistry.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java index e0dd5796b6..c5218e88d5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.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. @@ -277,7 +277,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements @Override public boolean containsSingleton(String beanName) { - return (this.singletonObjects.containsKey(beanName)); + return this.singletonObjects.containsKey(beanName); } @Override @@ -330,8 +330,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements * @see #isSingletonCurrentlyInCreation */ protected void beforeSingletonCreation(String beanName) { - if (!this.inCreationCheckExclusions.contains(beanName) && - !this.singletonsCurrentlyInCreation.add(beanName)) { + if (!this.inCreationCheckExclusions.contains(beanName) && !this.singletonsCurrentlyInCreation.add(beanName)) { throw new BeanCurrentlyInCreationException(beanName); } } @@ -343,8 +342,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements * @see #isSingletonCurrentlyInCreation */ protected void afterSingletonCreation(String beanName) { - if (!this.inCreationCheckExclusions.contains(beanName) && - !this.singletonsCurrentlyInCreation.remove(beanName)) { + if (!this.inCreationCheckExclusions.contains(beanName) && !this.singletonsCurrentlyInCreation.remove(beanName)) { throw new IllegalStateException("Singleton '" + beanName + "' isn't currently in creation"); } } 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 0bfcb375da..70adeede2b 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 e9f4b1c22e..420e10f27a 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,29 +13,30 @@ * 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.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.core.Conventions; -import org.springframework.util.StringUtils; 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.ConstructorArgumentValues.ValueHolder; +import org.springframework.beans.factory.config.RuntimeBeanReference; +import org.springframework.core.Conventions; +import org.springframework.util.StringUtils; + /** * Simple {@code NamespaceHandler} implementation that maps custom * attributes directly through to bean properties. An important point to note is * 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 24467400fa..7a827c9481 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-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java
index 936139f3a2..4b1274bc1e 100644
--- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java
+++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java
@@ -311,7 +311,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
 	 * reference into the JobDataMap but rather into the SchedulerContext.
 	 * @param schedulerContextAsMap Map with String keys and any objects as
 	 * values (for example Spring-managed beans)
-	 * @see JobDetailBean#setJobDataAsMap
+	 * @see JobDetailFactoryBean#setJobDataAsMap
 	 */
 	public void setSchedulerContextAsMap(Map schedulerContextAsMap) {
 		this.schedulerContextMap = schedulerContextAsMap;
@@ -329,8 +329,8 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
 	 * correspond to a "setApplicationContext" method in that scenario.
 	 * 

Note that BeanFactory callback interfaces like ApplicationContextAware * are not automatically applied to Quartz Job instances, because Quartz - * itself is reponsible for the lifecycle of its Jobs. - * @see JobDetailBean#setApplicationContextJobDataKey + * itself is responsible for the lifecycle of its Jobs. + * @see JobDetailFactoryBean#setApplicationContextJobDataKey * @see org.springframework.context.ApplicationContext */ public void setApplicationContextSchedulerContextKey(String applicationContextSchedulerContextKey) { 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 b966fc232d..0e11cc8662 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 @@ -74,7 +75,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)); @@ -177,8 +179,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser { /** * Simple, reusable class used for overriding defaults. - * - * @author Costin Leau */ private static class Props { @@ -190,7 +190,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser { private String[] caches = null; - Props(Element root) { String defaultCache = root.getAttribute("cache"); key = root.getAttribute("key"); @@ -202,7 +201,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser { } } - T merge(Element element, ReaderContext readerCtx, T op) { String cache = element.getAttribute("cache"); @@ -210,7 +208,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); } @@ -224,16 +223,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/format/AnnotationFormatterFactory.java b/spring-context/src/main/java/org/springframework/format/AnnotationFormatterFactory.java index dd0f12dd96..aaa5e720e1 100644 --- a/spring-context/src/main/java/org/springframework/format/AnnotationFormatterFactory.java +++ b/spring-context/src/main/java/org/springframework/format/AnnotationFormatterFactory.java @@ -13,13 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.format; import java.lang.annotation.Annotation; import java.util.Set; /** - * A factory that creates formatters to format values of fields annotated with a particular {@link Annotation}. + * A factory that creates formatters to format values of fields annotated with a particular + * {@link Annotation}. * *

For example, a {@code DateTimeFormatAnnotationFormatterFactory} might create a formatter * that formats {@code Date} values set on fields annotated with {@code @DateTimeFormat}. @@ -36,8 +38,10 @@ public interface AnnotationFormatterFactory { Set> getFieldTypes(); /** - * Get the Printer to print the value of a field of {@code fieldType} annotated with {@code annotation}. - * If the type <T> the printer accepts is not assignable to {@code fieldType}, a coercion from {@code fieldType} to <T> will be attempted before the Printer is invoked. + * Get the Printer to print the value of a field of {@code fieldType} annotated with + * {@code annotation}. + *

If the type T the printer accepts is not assignable to {@code fieldType}, a + * coercion from {@code fieldType} to T will be attempted before the Printer is invoked. * @param annotation the annotation instance * @param fieldType the type of field that was annotated * @return the printer @@ -45,8 +49,10 @@ public interface AnnotationFormatterFactory { Printer getPrinter(A annotation, Class fieldType); /** - * Get the Parser to parse a submitted value for a field of {@code fieldType} annotated with {@code annotation}. - * If the object the parser returns is not assignable to {@code fieldType}, a coercion to {@code fieldType} will be attempted before the field is set. + * Get the Parser to parse a submitted value for a field of {@code fieldType} + * annotated with {@code annotation}. + *

If the object the parser returns is not assignable to {@code fieldType}, + * a coercion to {@code fieldType} will be attempted before the field is set. * @param annotation the annotation instance * @param fieldType the type of field that was annotated * @return the parser diff --git a/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java b/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java index fb79c71782..d9f9edae01 100644 --- a/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java +++ b/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.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. @@ -90,7 +90,7 @@ public class FormattingConversionService extends GenericConversionService @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public void addFormatterForFieldAnnotation(AnnotationFormatterFactory annotationFormatterFactory) { - final Class annotationType = (Class) + Class annotationType = (Class) GenericTypeResolver.resolveTypeArgument(annotationFormatterFactory.getClass(), AnnotationFormatterFactory.class); if (annotationType == null) { throw new IllegalArgumentException("Unable to extract parameterized Annotation type argument from AnnotationFormatterFactory [" + @@ -100,7 +100,7 @@ public class FormattingConversionService extends GenericConversionService ((EmbeddedValueResolverAware) annotationFormatterFactory).setEmbeddedValueResolver(this.embeddedValueResolver); } Set> fieldTypes = annotationFormatterFactory.getFieldTypes(); - for (final Class fieldType : fieldTypes) { + for (Class fieldType : fieldTypes) { addConverter(new AnnotationPrinterConverter(annotationType, annotationFormatterFactory, fieldType)); addConverter(new AnnotationParserConverter(annotationType, annotationFormatterFactory, fieldType)); } @@ -109,14 +109,14 @@ public class FormattingConversionService extends GenericConversionService private static class PrinterConverter implements GenericConverter { - private Class fieldType; + private final Class fieldType; - private TypeDescriptor printerObjectType; + private final TypeDescriptor printerObjectType; @SuppressWarnings("rawtypes") - private Printer printer; + private final Printer printer; - private ConversionService conversionService; + private final ConversionService conversionService; public PrinterConverter(Class fieldType, Printer printer, ConversionService conversionService) { this.fieldType = fieldType; @@ -155,11 +155,11 @@ public class FormattingConversionService extends GenericConversionService private static class ParserConverter implements GenericConverter { - private Class fieldType; + private final Class fieldType; - private Parser parser; + private final Parser parser; - private ConversionService conversionService; + private final ConversionService conversionService; public ParserConverter(Class fieldType, Parser parser, ConversionService conversionService) { this.fieldType = fieldType; @@ -204,12 +204,12 @@ public class FormattingConversionService extends GenericConversionService private class AnnotationPrinterConverter implements ConditionalGenericConverter { - private Class annotationType; + private final Class annotationType; @SuppressWarnings("rawtypes") - private AnnotationFormatterFactory annotationFormatterFactory; + private final AnnotationFormatterFactory annotationFormatterFactory; - private Class fieldType; + private final Class fieldType; public AnnotationPrinterConverter(Class annotationType, AnnotationFormatterFactory annotationFormatterFactory, Class fieldType) { @@ -220,24 +220,24 @@ public class FormattingConversionService extends GenericConversionService @Override public Set getConvertibleTypes() { - return Collections.singleton(new ConvertiblePair(fieldType, String.class)); + return Collections.singleton(new ConvertiblePair(this.fieldType, String.class)); } @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { - return sourceType.hasAnnotation(annotationType); + return sourceType.hasAnnotation(this.annotationType); } @Override @SuppressWarnings("unchecked") public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { AnnotationConverterKey converterKey = - new AnnotationConverterKey(sourceType.getAnnotation(annotationType), sourceType.getObjectType()); + new AnnotationConverterKey(sourceType.getAnnotation(this.annotationType), sourceType.getObjectType()); GenericConverter converter = cachedPrinters.get(converterKey); if (converter == null) { - Printer printer = annotationFormatterFactory.getPrinter( + Printer printer = this.annotationFormatterFactory.getPrinter( converterKey.getAnnotation(), converterKey.getFieldType()); - converter = new PrinterConverter(fieldType, printer, FormattingConversionService.this); + converter = new PrinterConverter(this.fieldType, printer, FormattingConversionService.this); cachedPrinters.put(converterKey, converter); } return converter.convert(source, sourceType, targetType); @@ -245,20 +245,20 @@ public class FormattingConversionService extends GenericConversionService @Override public String toString() { - return "@" + annotationType.getName() + " " + fieldType.getName() + " -> " + - String.class.getName() + ": " + annotationFormatterFactory; + return "@" + this.annotationType.getName() + " " + this.fieldType.getName() + " -> " + + String.class.getName() + ": " + this.annotationFormatterFactory; } } private class AnnotationParserConverter implements ConditionalGenericConverter { - private Class annotationType; + private final Class annotationType; @SuppressWarnings("rawtypes") - private AnnotationFormatterFactory annotationFormatterFactory; + private final AnnotationFormatterFactory annotationFormatterFactory; - private Class fieldType; + private final Class fieldType; public AnnotationParserConverter(Class annotationType, AnnotationFormatterFactory annotationFormatterFactory, Class fieldType) { @@ -274,19 +274,19 @@ public class FormattingConversionService extends GenericConversionService @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { - return targetType.hasAnnotation(annotationType); + return targetType.hasAnnotation(this.annotationType); } @Override @SuppressWarnings("unchecked") public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { AnnotationConverterKey converterKey = - new AnnotationConverterKey(targetType.getAnnotation(annotationType), targetType.getObjectType()); + new AnnotationConverterKey(targetType.getAnnotation(this.annotationType), targetType.getObjectType()); GenericConverter converter = cachedParsers.get(converterKey); if (converter == null) { - Parser parser = annotationFormatterFactory.getParser( + Parser parser = this.annotationFormatterFactory.getParser( converterKey.getAnnotation(), converterKey.getFieldType()); - converter = new ParserConverter(fieldType, parser, FormattingConversionService.this); + converter = new ParserConverter(this.fieldType, parser, FormattingConversionService.this); cachedParsers.put(converterKey, converter); } return converter.convert(source, sourceType, targetType); @@ -294,8 +294,8 @@ public class FormattingConversionService extends GenericConversionService @Override public String toString() { - return String.class.getName() + " -> @" + annotationType.getName() + " " + - fieldType.getName() + ": " + annotationFormatterFactory; + return String.class.getName() + " -> @" + this.annotationType.getName() + " " + + this.fieldType.getName() + ": " + this.annotationFormatterFactory; } } @@ -312,25 +312,28 @@ public class FormattingConversionService extends GenericConversionService } public Annotation getAnnotation() { - return annotation; + return this.annotation; } public Class getFieldType() { - return fieldType; + return this.fieldType; } @Override - public boolean equals(Object o) { - if (!(o instanceof AnnotationConverterKey)) { + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof AnnotationConverterKey)) { return false; } - AnnotationConverterKey key = (AnnotationConverterKey) o; - return this.annotation.equals(key.annotation) && this.fieldType.equals(key.fieldType); + AnnotationConverterKey otherKey = (AnnotationConverterKey) other; + return (this.annotation.equals(otherKey.annotation) && this.fieldType.equals(otherKey.fieldType)); } @Override public int hashCode() { - return this.annotation.hashCode() + 29 * this.fieldType.hashCode(); + return (this.annotation.hashCode() + 29 * this.fieldType.hashCode()); } } 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 e8135d799f..c7093c7bd8 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 fece173a26..d1b02f758d 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 3c21a8e7dd..d49122fec7 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 32b2510901..99cb23953b 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/validation/DefaultMessageCodesResolver.java b/spring-context/src/main/java/org/springframework/validation/DefaultMessageCodesResolver.java index 4973f1e480..0eee6f1bbc 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 f016ca1d9a..c94fa01dea 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 9697aa8173..439f66b979 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 0aa414012d..bdab6cc987 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/ArrayToArrayConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/ArrayToArrayConverter.java index 0fb2f4de17..bdad578fc5 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/ArrayToArrayConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/ArrayToArrayConverter.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. @@ -40,11 +40,13 @@ final class ArrayToArrayConverter implements ConditionalGenericConverter { private final ConversionService conversionService; + public ArrayToArrayConverter(ConversionService conversionService) { this.helperConverter = new CollectionToArrayConverter(conversionService); this.conversionService = conversionService; } + @Override public Set getConvertibleTypes() { return Collections.singleton(new ConvertiblePair(Object[].class, Object[].class)); @@ -56,12 +58,10 @@ final class ArrayToArrayConverter implements ConditionalGenericConverter { } @Override - public Object convert(Object source, TypeDescriptor sourceType, - TypeDescriptor targetType) { - if ((conversionService instanceof GenericConversionService) - && ((GenericConversionService) conversionService).canBypassConvert( - sourceType.getElementTypeDescriptor(), - targetType.getElementTypeDescriptor())) { + public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { + if (this.conversionService instanceof GenericConversionService && + ((GenericConversionService) this.conversionService).canBypassConvert( + sourceType.getElementTypeDescriptor(), targetType.getElementTypeDescriptor())) { return source; } List sourceList = Arrays.asList(ObjectUtils.toObjectArray(source)); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/ArrayToStringConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/ArrayToStringConverter.java index 85326e4b60..ff9db8ef3f 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/ArrayToStringConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/ArrayToStringConverter.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. @@ -27,7 +27,8 @@ import org.springframework.util.ObjectUtils; /** * Converts an Array to a comma-delimited String. - * This implementation first adapts the source Array to a List, then delegates to {@link CollectionToStringConverter} to perform the target String conversion. + * This implementation first adapts the source Array to a List, + * then delegates to {@link CollectionToStringConverter} to perform the target String conversion. * * @author Keith Donald * @since 3.0 @@ -36,10 +37,12 @@ final class ArrayToStringConverter implements ConditionalGenericConverter { private final CollectionToStringConverter helperConverter; + public ArrayToStringConverter(ConversionService conversionService) { this.helperConverter = new CollectionToStringConverter(conversionService); } + @Override public Set getConvertibleTypes() { return Collections.singleton(new ConvertiblePair(Object[].class, String.class)); 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 eadacf3071..1222815617 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 2049dca6b8..9c23d2c769 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 09fbc8f650..7fec5eb48f 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 b97335a83b..48e6a0aef2 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 8dd0e7d57a..cd00102035 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/util/ObjectUtils.java b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java index 5d6b9c5e5d..218d43fd3b 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 28444526ad..ec44c24fa8 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 1f7552b57a..0c97499113 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 b9c6161038..04c8edfa94 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 dce6143963..b0c6e18283 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/standard/InternalSpelExpressionParser.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java index c459937fef..f3ddb6bd13 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java @@ -316,13 +316,15 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { SpelNodeImpl expr = null; if (peekToken(TokenKind.DOT,TokenKind.SAFE_NAVI)) { expr = eatDottedNode(); - } else { + } + else { expr = maybeEatNonDottedNode(); } if (expr==null) { return false; - } else { + } + else { push(expr); return true; } @@ -572,7 +574,8 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { List 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()])); @@ -599,7 +602,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); @@ -624,13 +627,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, @@ -641,10 +644,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(); @@ -667,9 +670,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 @@ -784,7 +785,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()) { @@ -807,10 +808,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; @@ -825,7 +826,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { return false; } Token t = peekToken(); - if (t.kind==desiredTokenKind) { + if (t.kind == desiredTokenKind) { if (consumeIfMatched) { this.tokenStreamPointer++; } @@ -835,7 +836,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; } @@ -848,7 +849,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) { @@ -924,14 +925,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 f7e1009864..49f93ae9c7 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 adb09f082c..24e66c42fe 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-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java index 21e8af20c7..5d37c668c0 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.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. @@ -393,7 +393,7 @@ public class SingleConnectionFactory /** * Create a default Session for this ConnectionFactory, - * adaptign to JMS 1.0.2 style queue/topic mode if necessary. + * adapting to JMS 1.0.2 style queue/topic mode if necessary. * @param con the JMS Connection to operate on * @param mode the Session acknowledgement mode * ({@code Session.TRANSACTED} or one of the common modes) diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/endpoint/DefaultJmsActivationSpecFactory.java b/spring-jms/src/main/java/org/springframework/jms/listener/endpoint/DefaultJmsActivationSpecFactory.java index 85c9179298..b4363002f4 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/endpoint/DefaultJmsActivationSpecFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/endpoint/DefaultJmsActivationSpecFactory.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. @@ -26,7 +26,7 @@ import org.springframework.beans.BeanWrapper; /** * Default implementation of the {@link JmsActivationSpecFactory} interface. - * Supports the standard JMS properties as defined by the JMS 1.5 specification, + * Supports the standard JMS properties as defined by the JCA 1.5 specification, * as well as Spring's extended "maxConcurrency" and "prefetchSize" settings * through autodetection of well-known vendor-specific provider properties. * @@ -158,7 +158,7 @@ public class DefaultJmsActivationSpecFactory extends StandardJmsActivationSpecFa // JORAM bw.setPropertyValue("maxMessages", Integer.toString(config.getPrefetchSize())); } - else if(bw.isWritableProperty("maxBatchSize")){ + else if (bw.isWritableProperty("maxBatchSize")){ // WebSphere bw.setPropertyValue("maxBatchSize", Integer.toString(config.getPrefetchSize())); } diff --git a/spring-jms/src/main/java/org/springframework/jms/support/JmsAccessor.java b/spring-jms/src/main/java/org/springframework/jms/support/JmsAccessor.java index 70b06ad033..a41d613edb 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/JmsAccessor.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/JmsAccessor.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. @@ -86,7 +86,7 @@ public abstract class JmsAccessor implements InitializingBean { *

Setting this flag to "true" will use a short local JMS transaction * when running outside of a managed transaction, and a synchronized local * JMS transaction in case of a managed transaction (other than an XA - * transaction) being present. The latter has the effect of a local JMS + * transaction) being present. This has the effect of a local JMS * transaction being managed alongside the main transaction (which might * be a native JDBC transaction), with the JMS transaction committing * right after the main transaction. @@ -109,7 +109,7 @@ public abstract class JmsAccessor implements InitializingBean { * Set the JMS acknowledgement mode by the name of the corresponding constant * in the JMS {@link Session} interface, e.g. "CLIENT_ACKNOWLEDGE". *

If you want to use vendor-specific extensions to the acknowledgment mode, - * use {@link #setSessionAcknowledgeModeName(String)} instead. + * use {@link #setSessionAcknowledgeMode(int)} instead. * @param constantName the name of the {@link Session} acknowledge mode constant * @see javax.jms.Session#AUTO_ACKNOWLEDGE * @see javax.jms.Session#CLIENT_ACKNOWLEDGE @@ -125,8 +125,8 @@ public abstract class JmsAccessor implements InitializingBean { * {@link Session} to send a message. *

Default is {@link Session#AUTO_ACKNOWLEDGE}. *

Vendor-specific extensions to the acknowledgment mode can be set here as well. - *

Note that that inside an EJB the parameters to - * create(Queue/Topic)Session(boolean transacted, int acknowledgeMode) method + *

Note that that inside an EJB, the parameters to the + * {@code create(Queue/Topic)Session(boolean transacted, int acknowledgeMode)} method * are not taken into account. Depending on the transaction context in the EJB, * the container makes its own decisions on these values. See section 17.3.5 * of the EJB spec. 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 9dd2eba0a6..f9bccb8d3b 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/broker/AbstractBrokerMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java index be34a11b9d..6f7a6b7e16 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java @@ -39,7 +39,7 @@ import org.springframework.util.CollectionUtils; * @since 4.0 */ public abstract class AbstractBrokerMessageHandler - implements MessageHandler, SmartLifecycle, ApplicationEventPublisherAware { + implements MessageHandler, ApplicationEventPublisherAware, SmartLifecycle { protected final Log logger = LogFactory.getLog(getClass()); @@ -51,10 +51,10 @@ public abstract class AbstractBrokerMessageHandler private boolean autoStartup = true; - private Object lifecycleMonitor = new Object(); - private volatile boolean running = false; + private final Object lifecycleMonitor = new Object(); + public AbstractBrokerMessageHandler() { this(Collections.emptyList()); @@ -95,7 +95,6 @@ public abstract class AbstractBrokerMessageHandler /** * Check whether this message handler is currently running. - * *

Note that even when this message handler is running the * {@link #isBrokerAvailable()} flag may still independently alternate between * being on and off depending on the concrete sub-class implementation. @@ -107,23 +106,6 @@ public abstract class AbstractBrokerMessageHandler } } - /** - * Whether the message broker is currently available and able to process messages. - * - *

Note that this is in addition to the {@link #isRunning()} flag, which - * indicates whether this message handler is running. In other words the message - * handler must first be running and then the {@link #isBrokerAvailable()} flag - * may still independently alternate between being on and off depending on the - * concrete sub-class implementation. - * - *

Application components may implement - * {@link org.springframework.context.ApplicationListener>} - * to receive notifications when broker becomes available and unavailable. - */ - public boolean isBrokerAvailable() { - return this.brokerAvailable.get(); - } - @Override public final void start() { synchronized (this.lifecycleMonitor) { @@ -166,6 +148,22 @@ public abstract class AbstractBrokerMessageHandler } } + /** + * Whether the message broker is currently available and able to process messages. + *

Note that this is in addition to the {@link #isRunning()} flag, which + * indicates whether this message handler is running. In other words the message + * handler must first be running and then the {@code #isBrokerAvailable()} flag + * may still independently alternate between being on and off depending on the + * concrete sub-class implementation. + *

Application components may implement + * {@code org.springframework.context.ApplicationListener<BrokerAvailabilityEvent>} + * to receive notifications when broker becomes available and unavailable. + */ + public boolean isBrokerAvailable() { + return this.brokerAvailable.get(); + } + + @Override public final void handleMessage(Message message) { if (!this.running) { 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 895fbfda92..dbe5c47f06 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 @@ -316,7 +316,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); @@ -331,7 +331,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 6a61943a42..d913013a49 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 @@ -319,7 +319,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 dc10a92753..c0580f1816 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 395442fee6..525197336a 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 95f093bf89..1f12c29325 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 9b247990d1..db38ef36d3 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 67d86ca76a..8fcd55f547 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 @@ -76,7 +76,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); } @@ -110,7 +110,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 29e2845be3..fb0e553c56 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 d15037ccd0..58841e2278 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/feed/AbstractWireFeedHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java index d8151cf58b..eab30f1bb6 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java @@ -62,12 +62,8 @@ public abstract class AbstractWireFeedHttpMessageConverter 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/http/converter/json/Jackson2ObjectMapperFactoryBean.java b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBean.java index e99d8451f2..eedcf5456a 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBean.java @@ -334,7 +334,7 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean(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 dfbc21530f..b20a79fe73 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 37e9c015ff..43db6b06ef 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 4c0c7234ef..d762eb60fa 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; } } @@ -227,7 +227,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 19c170c9d6..46af047ad8 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 619252bf7f..8e64fd8f70 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 1355a991cf..4e9d4b1bdf 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/mvc/condition/ProducesRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ProducesRequestCondition.java index 684d239091..c51f16fbe7 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/tags/MessageTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/MessageTag.java index 1ff54e05aa..f513af29d5 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 09b7e8f000..518722fdd2 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 02b5b9b7a8..5400abe27e 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,19 +35,20 @@ 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 void setShowPassword(boolean showPassword) { + this.showPassword = showPassword; + } + + /** + * Is the password value to be rendered? + * @return {@code true} if the password value to be rendered */ public boolean isShowPassword() { return this.showPassword; } - /** - * Is the password value to be rendered? - * @param showPassword {@code true} if the password value is to be rendered. - */ - public void setShowPassword(boolean showPassword) { - this.showPassword = 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/tiles2/TilesConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/TilesConfigurer.java index 41d28597f5..e1bc135294 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/TilesConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/TilesConfigurer.java @@ -257,7 +257,7 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D } /** - * Creates a new instance of {@link SpringTilesInitializer}. + * Creates a new instance of {@code SpringTilesInitializer}. *

Override it to use a different initializer. * @see org.apache.tiles.web.startup.AbstractTilesListener#createTilesInitializer() */ 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 9c1af58841..159b145117 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 67c534a954..862de0a382 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 27aa8030bd..c21fd301e1 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/server/jetty/JettyRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java index b3e4b041c2..714b2957e8 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 763906f41a..5d9382117c 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 1e2d301dbe..7f733e62c9 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(); } } -