diff --git a/build.gradle b/build.gradle index 85b1d260626..314f67a6f42 100644 --- a/build.gradle +++ b/build.gradle @@ -879,10 +879,10 @@ project("spring-webmvc") { testCompile("commons-io:commons-io:1.3") testCompile("joda-time:joda-time:${jodaVersion}") testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}") - testCompile("org.jruby:jruby:${jrubyVersion}") - testCompile("org.python:jython-standalone:2.5.3") testCompile("org.mozilla:rhino:1.7.7.1") - testCompile("org.webjars:underscorejs:1.8.3") + testRuntime("org.jruby:jruby:${jrubyVersion}") + testRuntime("org.python:jython-standalone:2.5.3") + testRuntime("org.webjars:underscorejs:1.8.3") } } diff --git a/spring-aop/src/main/java/org/aopalliance/intercept/MethodInterceptor.java b/spring-aop/src/main/java/org/aopalliance/intercept/MethodInterceptor.java index 7fa2b872691..c08fd7443f2 100644 --- a/spring-aop/src/main/java/org/aopalliance/intercept/MethodInterceptor.java +++ b/spring-aop/src/main/java/org/aopalliance/intercept/MethodInterceptor.java @@ -46,7 +46,7 @@ public interface MethodInterceptor extends Interceptor { * after the invocation. Polite implementations would certainly * like to invoke {@link Joinpoint#proceed()}. * @param invocation the method invocation joinpoint - * @return the result of the call to {@link Joinpoint#proceed(); + * @return the result of the call to {@link Joinpoint#proceed()}; * might be intercepted by the interceptor * @throws Throwable if the interceptors or the target object * throws an exception 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 9928530dbd4..908bfeafe66 100644 --- a/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java @@ -269,7 +269,7 @@ class TypeConverterDelegate { } else { // convertedValue == null - if (javaUtilOptionalEmpty != null && requiredType.equals(javaUtilOptionalEmpty.getClass())) { + if (javaUtilOptionalEmpty != null && requiredType == javaUtilOptionalEmpty.getClass()) { convertedValue = javaUtilOptionalEmpty; } } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 6205fa69cfe..9cc3c907ea4 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -1002,7 +1002,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto Set autowiredBeanNames, TypeConverter typeConverter) throws BeansException { descriptor.initParameterNameDiscovery(getParameterNameDiscoverer()); - if (descriptor.getDependencyType().equals(javaUtilOptionalClass)) { + if (javaUtilOptionalClass == descriptor.getDependencyType()) { return new OptionalDependencyFactory().createOptionalDependency(descriptor, beanName); } else if (ObjectFactory.class == descriptor.getDependencyType() || diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java index d2ac971cbc9..91ad5d8e96c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 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. @@ -125,7 +125,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition { setBeanClass(beanClass); setAutowireMode(autowireMode); if (dependencyCheck && getResolvedAutowireMode() != AUTOWIRE_CONSTRUCTOR) { - setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS); + setDependencyCheck(DEPENDENCY_CHECK_OBJECTS); } } diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/package-info.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/package-info.java index 4291b2deae8..edb951a4ce5 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/package-info.java +++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/package-info.java @@ -7,6 +7,6 @@ *

Note: EhCache 3.x lives in a different package namespace * and is not covered by the traditional support classes here. * Instead, consider using it through JCache (JSR-107), with - * Spring's support in {@link org.springframework.cache.jcache}. + * Spring's support in {@code org.springframework.cache.jcache}. */ package org.springframework.cache.ehcache; diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java index f99b40d756e..f7f6fa4ec7c 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -52,7 +52,7 @@ public class CachingConfigurationSelector extends AdviceModeImportSelector result = new ArrayList(); result.add(AutoProxyRegistrar.class.getName()); result.add(ProxyCachingConfiguration.class.getName()); - if (jsr107Present && jCacheImplPresent) { + if (jsr107Present && jcacheImplPresent) { result.add(PROXY_JCACHE_CONFIGURATION_CLASS); } return result.toArray(new String[result.size()]); @@ -94,7 +94,7 @@ public class CachingConfigurationSelector extends AdviceModeImportSelector result = new ArrayList(); result.add(CACHE_ASPECT_CONFIGURATION_CLASS_NAME); - if (jsr107Present && jCacheImplPresent) { + if (jsr107Present && jcacheImplPresent) { result.add(JCACHE_ASPECT_CONFIGURATION_CLASS_NAME); } return result.toArray(new String[result.size()]); diff --git a/spring-context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java b/spring-context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java index 4ea5ccad0aa..d9f90dc2f14 100644 --- a/spring-context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java +++ b/spring-context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -60,11 +60,10 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser private static final String JCACHE_ASPECT_CLASS_NAME = "org.springframework.cache.aspectj.JCacheCacheAspect"; - private static final boolean jsr107Present = ClassUtils.isPresent( "javax.cache.Cache", AnnotationDrivenCacheBeanDefinitionParser.class.getClassLoader()); - private static final boolean jCacheImplPresent = ClassUtils.isPresent( + private static final boolean jcacheImplPresent = ClassUtils.isPresent( "org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource", AnnotationDrivenCacheBeanDefinitionParser.class.getClassLoader()); @@ -91,7 +90,7 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser private void registerCacheAspect(Element element, ParserContext parserContext) { SpringCachingConfigurer.registerCacheAspect(element, parserContext); - if (jsr107Present && jCacheImplPresent) { // Register JCache aspect + if (jsr107Present && jcacheImplPresent) { JCacheCachingConfigurer.registerCacheAspect(element, parserContext); } } @@ -99,7 +98,7 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser private void registerCacheAdvisor(Element element, ParserContext parserContext) { AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element); SpringCachingConfigurer.registerCacheAdvisor(element, parserContext); - if (jsr107Present && jCacheImplPresent) { // Register JCache advisor + if (jsr107Present && jcacheImplPresent) { JCacheCachingConfigurer.registerCacheAdvisor(element, parserContext); } } diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java index 8901ba1945c..3529438d784 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java @@ -30,9 +30,8 @@ package org.springframework.cache.interceptor; public interface CacheOperationInvoker { /** - * Invoke the cache operation defined by this instance. Wraps any - * exception that is thrown during the invocation in a - * {@link ThrowableWrapper}. + * Invoke the cache operation defined by this instance. Wraps any exception + * that is thrown during the invocation in a {@link ThrowableWrapper}. * @return the result of the operation * @throws ThrowableWrapper if an error occurred while invoking the operation */ diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotatedBeanDefinitionReader.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotatedBeanDefinitionReader.java index 780f8be00b6..4c16bb0e64c 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotatedBeanDefinitionReader.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotatedBeanDefinitionReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 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. @@ -127,15 +127,13 @@ public class AnnotatedBeanDefinitionReader { registerBean(annotatedClass, null, (Class[]) null); } - public void registerBean(Class annotatedClass, - @SuppressWarnings("unchecked") Class... qualifiers) { - + @SuppressWarnings("unchecked") + public void registerBean(Class annotatedClass, Class... qualifiers) { registerBean(annotatedClass, null, qualifiers); } - public void registerBean(Class annotatedClass, String name, - @SuppressWarnings("unchecked") Class... qualifiers) { - + @SuppressWarnings("unchecked") + public void registerBean(Class annotatedClass, String name, Class... qualifiers) { AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass); if (this.conditionEvaluator.shouldSkip(abd.getMetadata())) { return; diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java index 9ab27884430..10d7c7ac1ca 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java @@ -466,7 +466,7 @@ public class GroovyScriptFactoryTests { @Test // SPR-6268 public void testProxyTargetClassNotAllowedIfNotGroovy() throws Exception { try { - new ClassPathXmlApplicationContext("jruby-with-xsd-proxy-target-class.xml", getClass()); + new ClassPathXmlApplicationContext("groovy-with-xsd-proxy-target-class.xml", getClass()); } catch (BeanCreationException ex) { assertTrue(ex.getMessage().contains("Cannot use proxyTargetClass=true")); diff --git a/spring-context/src/test/resources/org/springframework/scripting/groovy/jruby-with-xsd-proxy-target-class.xml b/spring-context/src/test/resources/org/springframework/scripting/groovy/jruby-with-xsd-proxy-target-class.xml deleted file mode 100644 index 58a9b4027b4..00000000000 --- a/spring-context/src/test/resources/org/springframework/scripting/groovy/jruby-with-xsd-proxy-target-class.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - diff --git a/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java b/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java index 5a2b2df765d..804c26e74ba 100644 --- a/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java +++ b/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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,10 +85,9 @@ public abstract class MethodIntrospector { /** * Select methods on the given target type based on a filter. - *

Callers define methods of interest through the - * {@link ReflectionUtils.MethodFilter} parameter. + *

Callers define methods of interest through the {@code MethodFilter} parameter. * @param targetType the target type to search methods on - * @param methodFilter a {@link ReflectionUtils.MethodFilter} to help + * @param methodFilter a {@code MethodFilter} to help * recognize handler methods of interest * @return the selected methods, or an empty set in case of no match */ diff --git a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java index dd5f180180d..ffbbd7ab0d0 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java +++ b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java @@ -343,7 +343,7 @@ public class TypeDescriptor implements Serializable { if (streamAvailable && StreamDelegate.isStream(this.type)) { return StreamDelegate.getStreamElementType(this); } - return getRelatedIfResolvable(this, this.resolvableType.asCollection().getGeneric()); + return getRelatedIfResolvable(this, this.resolvableType.asCollection().getGeneric(0)); } /** @@ -706,7 +706,7 @@ public class TypeDescriptor implements Serializable { } public static TypeDescriptor getStreamElementType(TypeDescriptor source) { - return getRelatedIfResolvable(source, source.resolvableType.as(Stream.class).getGeneric()); + return getRelatedIfResolvable(source, source.resolvableType.as(Stream.class).getGeneric(0)); } } diff --git a/spring-core/src/main/java/org/springframework/util/Base64Utils.java b/spring-core/src/main/java/org/springframework/util/Base64Utils.java index 17c48614b83..f10b60d62f0 100644 --- a/spring-core/src/main/java/org/springframework/util/Base64Utils.java +++ b/spring-core/src/main/java/org/springframework/util/Base64Utils.java @@ -30,11 +30,11 @@ import org.springframework.lang.UsesJava8; * Codec present, {@link #encode}/{@link #decode} calls will throw an IllegalStateException. * However, as of Spring 4.2, {@link #encodeToString} and {@link #decodeFromString} will * nevertheless work since they can delegate to the JAXB DatatypeConverter as a fallback. - * However, this does not apply when using the ...UrlSafe... methods for RFC 4648 "URL and + * However, this does not apply when using the "UrlSafe" methods for RFC 4648 "URL and * Filename Safe Alphabet"; a delegate is required. - *

- * Note: Apache Commons Codec does not add padding ({@code =}) when encoding with - * the URL and Filename Safe Alphabet. + * + *

Note: Apache Commons Codec does not add padding ({@code =}) when encoding + * with the URL and Filename Safe Alphabet. * * @author Juergen Hoeller * @author Gary Russell diff --git a/spring-core/src/main/java/org/springframework/util/DigestUtils.java b/spring-core/src/main/java/org/springframework/util/DigestUtils.java index 8de0b513cdc..6251c7aa968 100644 --- a/spring-core/src/main/java/org/springframework/util/DigestUtils.java +++ b/spring-core/src/main/java/org/springframework/util/DigestUtils.java @@ -24,13 +24,12 @@ import java.security.NoSuchAlgorithmException; /** * Miscellaneous methods for calculating digests. *

Mainly for internal use within the framework; consider - * Apache Commons Codec for a - * more comprehensive suite of digest utilities. + * Apache Commons Codec + * for a more comprehensive suite of digest utilities. * * @author Arjen Poutsma * @author Craig Andrews * @since 3.0 - * @see org.apache.commons.codec.digest.DigestUtils */ public abstract class DigestUtils { diff --git a/spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java b/spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java index 37890be94f2..90bfa4a7e8d 100644 --- a/spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java +++ b/spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java @@ -33,7 +33,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream { * Update the message digest with the rest of the bytes in this stream. *

Using this method is more optimized since it avoids creating new * byte arrays for each call. - * @param messageDigest The message digest to update + * @param messageDigest the message digest to update * @throws IOException when propagated from {@link #read()} */ public void updateMessageDigest(MessageDigest messageDigest) throws IOException { @@ -47,7 +47,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream { * Update the message digest with the next len bytes in this stream. *

Using this method is more optimized since it avoids creating new * byte arrays for each call. - * @param messageDigest The message digest to update + * @param messageDigest the message digest to update * @param len how many bytes to read from this stream and use to update the message digest * @throws IOException when propagated from {@link #read()} */ diff --git a/spring-core/src/main/java/org/springframework/util/concurrent/CompletableToListenableFutureAdapter.java b/spring-core/src/main/java/org/springframework/util/concurrent/CompletableToListenableFutureAdapter.java index f42a88f4af4..1a6cd14fbdc 100644 --- a/spring-core/src/main/java/org/springframework/util/concurrent/CompletableToListenableFutureAdapter.java +++ b/spring-core/src/main/java/org/springframework/util/concurrent/CompletableToListenableFutureAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -24,7 +24,6 @@ import java.util.function.BiFunction; import org.springframework.lang.UsesJava8; - /** * Adapts a {@link CompletableFuture} into a {@link ListenableFuture}. * @@ -38,6 +37,7 @@ public class CompletableToListenableFutureAdapter implements ListenableFuture private final ListenableFutureCallbackRegistry callbacks = new ListenableFutureCallbackRegistry(); + public CompletableToListenableFutureAdapter(CompletableFuture completableFuture) { this.completableFuture = completableFuture; this.completableFuture.handle(new BiFunction() { @@ -54,6 +54,7 @@ public class CompletableToListenableFutureAdapter implements ListenableFuture }); } + @Override public void addCallback(ListenableFutureCallback callback) { this.callbacks.addCallback(callback); 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 37aac9310eb..2a36c9e6042 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-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -24,10 +24,9 @@ import java.util.concurrent.TimeoutException; import org.springframework.util.Assert; /** - * Abstract class that adapts a {@link Future} parameterized over S into a {@code - * Future} parameterized over T. All methods are delegated to the adaptee, where {@link - * #get()} and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's - * result. + * Abstract class that adapts a {@link Future} parameterized over S into a {@code Future} + * parameterized over T. All methods are delegated to the adaptee, where {@link #get()} + * and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's result. * * @author Arjen Poutsma * @since 4.0 diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java index 79dd4f07ddb..fda1f06dba5 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 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. @@ -30,13 +30,15 @@ import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; /** - * Unit tests for {@link AbstractPropertySource} implementations. + * Unit tests for {@link PropertySource} implementations. * * @author Chris Beams * @since 3.1 */ public class PropertySourceTests { - @Test @SuppressWarnings("serial") + + @Test + @SuppressWarnings("serial") public void equals() { Map map1 = new HashMap() {{ put("a", "b"); }}; Map map2 = new HashMap() {{ put("c", "d"); }}; @@ -59,14 +61,15 @@ public class PropertySourceTests { assertThat(new MapPropertySource("x", map1).equals(new PropertiesPropertySource("y", props2)), is(false)); } - @Test @SuppressWarnings("serial") + @Test + @SuppressWarnings("serial") public void collectionsOperations() { Map map1 = new HashMap() {{ put("a", "b"); }}; Map map2 = new HashMap() {{ put("c", "d"); }}; PropertySource ps1 = new MapPropertySource("ps1", map1); ps1.getSource(); - List> propertySources = new ArrayList>(); + List> propertySources = new ArrayList<>(); assertThat(propertySources.add(ps1), equalTo(true)); assertThat(propertySources.contains(ps1), is(true)); assertThat(propertySources.contains(PropertySource.named("ps1")), is(true)); @@ -116,4 +119,5 @@ public class PropertySourceTests { logger.setLevel(original); } } + } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java index 2d20e195d15..decb2f1cb43 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -147,6 +147,72 @@ public class CodeFlow implements Opcodes { } } + /** + * Called after the main expression evaluation method has been generated, this + * method will callback any registered FieldAdders or ClinitAdders to add any + * extra information to the class representing the compiled expression. + */ + public void finish() { + if (this.fieldAdders != null) { + for (FieldAdder fieldAdder : this.fieldAdders) { + fieldAdder.generateField(cw,this); + } + } + if (this.clinitAdders != null) { + MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "", "()V", null, null); + mv.visitCode(); + this.nextFreeVariableId = 0; // To 0 because there is no 'this' in a clinit + for (ClinitAdder clinitAdder : this.clinitAdders) { + clinitAdder.generateCode(mv, this); + } + mv.visitInsn(RETURN); + mv.visitMaxs(0,0); // not supplied due to COMPUTE_MAXS + mv.visitEnd(); + } + } + + /** + * Register a FieldAdder which will add a new field to the generated + * class to support the code produced by an ast nodes primary + * generateCode() method. + */ + public void registerNewField(FieldAdder fieldAdder) { + if (this.fieldAdders == null) { + this.fieldAdders = new ArrayList(); + } + this.fieldAdders.add(fieldAdder); + } + + /** + * Register a ClinitAdder which will add code to the static + * initializer in the generated class to support the code + * produced by an ast nodes primary generateCode() method. + */ + public void registerNewClinit(ClinitAdder clinitAdder) { + if (this.clinitAdders == null) { + this.clinitAdders = new ArrayList(); + } + this.clinitAdders.add(clinitAdder); + } + + public int nextFieldId() { + return this.nextFieldId++; + } + + public int nextFreeVariableId() { + return this.nextFreeVariableId++; + } + + public String getClassName() { + return this.clazzName; + } + + @Deprecated + public String getClassname() { + return this.clazzName; + } + + /** * Insert any necessary cast and value call to convert from a boxed type to a * primitive value @@ -778,74 +844,6 @@ public class CodeFlow implements Opcodes { return descriptors; } - /** - * Called after the main expression evaluation method has been generated, this - * method will callback any registered FieldAdders or ClinitAdders to add any - * extra information to the class representing the compiled expression. - */ - public void finish() { - if (fieldAdders != null) { - for (FieldAdder fieldAdder: fieldAdders) { - fieldAdder.generateField(cw,this); - } - } - if (clinitAdders != null) { - MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "", "()V", null, null); - mv.visitCode(); - nextFreeVariableId = 0; // To 0 because there is no 'this' in a clinit - for (ClinitAdder clinitAdder: clinitAdders) { - clinitAdder.generateCode(mv, this); - } - mv.visitInsn(RETURN); - mv.visitMaxs(0,0); // not supplied due to COMPUTE_MAXS - mv.visitEnd(); - } - } - - /** - * Register a FieldAdder which will add a new field to the generated - * class to support the code produced by an ast nodes primary - * generateCode() method. - */ - public void registerNewField(FieldAdder fieldAdder) { - if (fieldAdders == null) { - fieldAdders = new ArrayList(); - } - fieldAdders.add(fieldAdder); - } - - /** - * Register a ClinitAdder which will add code to the static - * initializer in the generated class to support the code - * produced by an ast nodes primary generateCode() method. - */ - public void registerNewClinit(ClinitAdder clinitAdder) { - if (clinitAdders == null) { - clinitAdders = new ArrayList(); - } - clinitAdders.add(clinitAdder); - } - - public int nextFieldId() { - return nextFieldId++; - } - - public int nextFreeVariableId() { - return nextFreeVariableId++; - } - - public String getClassname() { - return clazzName; - } - - public interface FieldAdder { - public void generateField(ClassWriter cw, CodeFlow codeflow); - } - - public interface ClinitAdder { - public void generateCode(MethodVisitor mv, CodeFlow codeflow); - } - /** * Create the optimal instruction for loading a number on the stack. * @param mv where to insert the bytecode @@ -977,4 +975,15 @@ public class CodeFlow implements Opcodes { } + public interface FieldAdder { + + void generateField(ClassWriter cw, CodeFlow codeflow); + } + + + public interface ClinitAdder { + + void generateCode(MethodVisitor mv, CodeFlow codeflow); + } + } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineList.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineList.java index b4134b6351e..1a435b861d9 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineList.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineList.java @@ -132,8 +132,8 @@ public class InlineList extends SpelNodeImpl { @Override public void generateCode(MethodVisitor mv, CodeFlow codeflow) { - final String constantFieldName = "inlineList$"+codeflow.nextFieldId(); - final String clazzname = codeflow.getClassname(); + final String constantFieldName = "inlineList$" + codeflow.nextFieldId(); + final String className = codeflow.getClassName(); codeflow.registerNewField(new CodeFlow.FieldAdder() { public void generateField(ClassWriter cw, CodeFlow codeflow) { @@ -143,11 +143,11 @@ public class InlineList extends SpelNodeImpl { codeflow.registerNewClinit(new CodeFlow.ClinitAdder() { public void generateCode(MethodVisitor mv, CodeFlow codeflow) { - generateClinitCode(clazzname,constantFieldName, mv,codeflow,false); + generateClinitCode(className, constantFieldName, mv, codeflow, false); } }); - mv.visitFieldInsn(GETSTATIC, clazzname, constantFieldName, "Ljava/util/List;"); + mv.visitFieldInsn(GETSTATIC, className, constantFieldName, "Ljava/util/List;"); codeflow.pushDescriptor("Ljava/util/List"); } @@ -158,8 +158,8 @@ public class InlineList extends SpelNodeImpl { if (!nested) { mv.visitFieldInsn(PUTSTATIC, clazzname, constantFieldName, "Ljava/util/List;"); } - int childcount = getChildCount(); - for (int c=0; c < childcount; c++) { + int childCount = getChildCount(); + for (int c = 0; c < childCount; c++) { if (!nested) { mv.visitFieldInsn(GETSTATIC, clazzname, constantFieldName, "Ljava/util/List;"); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java index 3af9f4635a9..3d7c25f1d3d 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -542,6 +542,7 @@ public abstract class AbstractJdbcInsert { * @param batch array of Maps with parameter names and values to be used in batch insert * @return array of number of rows affected */ + @SuppressWarnings("unchecked") protected int[] doExecuteBatch(Map... batch) { checkCompiled(); List> batchValues = new ArrayList>(batch.length); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsert.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsert.java index c5d15e78add..417423507fc 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsert.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsert.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -148,6 +148,7 @@ public class SimpleJdbcInsert extends AbstractJdbcInsert implements SimpleJdbcIn } @Override + @SuppressWarnings("unchecked") public int[] executeBatch(Map... batch) { return doExecuteBatch(batch); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertOperations.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertOperations.java index 0e1dd15ceb5..645a2a9785e 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertOperations.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertOperations.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -152,6 +152,7 @@ public interface SimpleJdbcInsertOperations { * @param batch an array of Maps containing a batch of column names and corresponding value * @return the array of number of rows affected as returned by the JDBC driver */ + @SuppressWarnings("unchecked") int[] executeBatch(Map... batch); /** diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/TransactionAwareConnectionFactoryProxy.java b/spring-jms/src/main/java/org/springframework/jms/connection/TransactionAwareConnectionFactoryProxy.java index 50c61409252..19a9ffc041a 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/TransactionAwareConnectionFactoryProxy.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/TransactionAwareConnectionFactoryProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -101,7 +101,7 @@ public class TransactionAwareConnectionFactoryProxy * Set the target ConnectionFactory that this ConnectionFactory should delegate to. */ public final void setTargetConnectionFactory(ConnectionFactory targetConnectionFactory) { - Assert.notNull(targetConnectionFactory, "targetConnectionFactory must not be nul"); + Assert.notNull(targetConnectionFactory, "'targetConnectionFactory' must not be null"); this.targetConnectionFactory = targetConnectionFactory; } diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointFactory.java b/spring-jms/src/main/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointFactory.java index fe448aa2bc9..5beb87333ea 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -61,7 +61,7 @@ public class JmsMessageEndpointFactory extends AbstractMessageEndpointFactory { * Return the JMS MessageListener for this endpoint. */ protected MessageListener getMessageListener() { - return messageListener; + return this.messageListener; } /** diff --git a/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java b/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java index 0767c15fb1f..5d9bc44b53f 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java @@ -196,6 +196,7 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B @Override public Message toMessage(Object object, Session session, Object conversionHint) throws JMSException, MessageConversionException { + return toMessage(object, session, getSerializationView(conversionHint)); } @@ -234,6 +235,7 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B protected Message toMessage(Object object, Session session, ObjectWriter objectWriter) throws JMSException, MessageConversionException { + Message message; try { switch (this.targetType) { @@ -319,8 +321,8 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B * @return the resulting message * @throws JMSException if thrown by JMS methods * @throws IOException in case of I/O errors - * @see Session#createBytesMessage * @since 4.3 + * @see Session#createBytesMessage */ protected BytesMessage mapToBytesMessage(Object object, Session session, ObjectWriter objectWriter) throws JMSException, IOException { @@ -400,7 +402,6 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B } } - /** * Convenience method to dispatch to converters for individual message types. */ diff --git a/spring-jms/src/main/java/org/springframework/jms/support/converter/MessagingMessageConverter.java b/spring-jms/src/main/java/org/springframework/jms/support/converter/MessagingMessageConverter.java index c791d289eec..fbd1d5adc60 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/converter/MessagingMessageConverter.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/converter/MessagingMessageConverter.java @@ -152,7 +152,4 @@ public class MessagingMessageConverter implements MessageConverter, Initializing return this.headerMapper.toHeaders(message); } - - - } 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 2d27db7d2b7..84d29f92961 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 @@ -86,7 +86,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC private static final String MVC_VALIDATOR_NAME = "mvcValidator"; - private static final boolean jackson2Present= ClassUtils.isPresent( + private static final boolean jackson2Present = ClassUtils.isPresent( "com.fasterxml.jackson.databind.ObjectMapper", AbstractMessageBrokerConfiguration.class.getClassLoader()); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/AbstractMessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/AbstractMessageConverterTests.java deleted file mode 100644 index 3f2524e81b7..00000000000 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/AbstractMessageConverterTests.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2002-2013 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.messaging.converter; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageHeaders; -import org.springframework.messaging.support.MessageBuilder; -import org.springframework.util.MimeType; -import org.springframework.util.MimeTypeUtils; - -import static org.junit.Assert.*; - -/** - * Test fixture for {@link org.springframework.messaging.converter.AbstractMessageConverter}. - * - * @author Rossen Stoyanchev - */ -public class AbstractMessageConverterTests { - - private TestMessageConverter converter; - - - @Before - public void setup() { - this.converter = new TestMessageConverter(); - this.converter.setContentTypeResolver(new DefaultContentTypeResolver()); - } - - @Test - public void supportsTargetClass() { - Message message = MessageBuilder.withPayload("ABC").build(); - - assertEquals("success-from", this.converter.fromMessage(message, String.class)); - assertNull(this.converter.fromMessage(message, Integer.class)); - } - - @Test - public void supportsMimeType() { - Message message = MessageBuilder.withPayload( - "ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build(); - - assertEquals("success-from", this.converter.fromMessage(message, String.class)); - } - - @Test - public void supportsMimeTypeNotSupported() { - Message message = MessageBuilder.withPayload( - "ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build(); - - assertNull(this.converter.fromMessage(message, String.class)); - } - - @Test - public void supportsMimeTypeNotSpecified() { - Message message = MessageBuilder.withPayload("ABC").build(); - assertEquals("success-from", this.converter.fromMessage(message, String.class)); - } - - @Test - public void supportsMimeTypeNoneConfigured() { - - Message message = MessageBuilder.withPayload( - "ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build(); - - this.converter = new TestMessageConverter(Collections.emptyList()); - this.converter.setContentTypeResolver(new DefaultContentTypeResolver()); - - assertEquals("success-from", this.converter.fromMessage(message, String.class)); - } - - @Test - public void toMessageHeadersCopied() { - Map map = new HashMap(); - map.put("foo", "bar"); - MessageHeaders headers = new MessageHeaders(map ); - Message message = this.converter.toMessage("ABC", headers); - - assertEquals("bar", message.getHeaders().get("foo")); - } - - @Test - public void toMessageContentTypeHeader() { - Message message = this.converter.toMessage("ABC", null); - assertEquals(MimeTypeUtils.TEXT_PLAIN, message.getHeaders().get(MessageHeaders.CONTENT_TYPE)); - } - - - private static class TestMessageConverter extends AbstractMessageConverter { - - public TestMessageConverter() { - super(MimeTypeUtils.TEXT_PLAIN); - } - - public TestMessageConverter(Collection supportedMimeTypes) { - super(supportedMimeTypes); - } - - @Override - protected boolean supports(Class clazz) { - return String.class.equals(clazz); - } - - @Override - public Object convertFromInternal(Message message, Class targetClass) { - return "success-from"; - } - - @Override - public Object convertToInternal(Object payload, MessageHeaders headers) { - return "success-to"; - } - } - -} diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java index f10f2a174ee..be6d9cf672f 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -44,6 +44,7 @@ public class MessageConverterTests { private TestMessageConverter converter = new TestMessageConverter(); + @Test public void supportsTargetClass() { Message message = MessageBuilder.withPayload("ABC").build(); @@ -105,7 +106,7 @@ public class MessageConverterTests { @Test public void toMessageWithHeaders() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("foo", "bar"); MessageHeaders headers = new MessageHeaders(map); Message message = this.converter.toMessage("ABC", headers); diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java index a3bac0ce612..46f6ae689de 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java @@ -115,11 +115,11 @@ public abstract class SharedEntityManagerCreator { */ public static EntityManager createSharedEntityManager( EntityManagerFactory emf, Map properties, boolean synchronizedWithTransaction) { - Class entityManagerInterface = (emf instanceof EntityManagerFactoryInfo ? + + Class emIfc = (emf instanceof EntityManagerFactoryInfo ? ((EntityManagerFactoryInfo) emf).getEntityManagerInterface() : EntityManager.class); return createSharedEntityManager(emf, properties, synchronizedWithTransaction, - (entityManagerInterface == null ? NO_ENTITY_MANAGER_INTERFACES : - new Class[] { entityManagerInterface })); + (emIfc == null ? NO_ENTITY_MANAGER_INTERFACES : new Class[] {emIfc})); } /** diff --git a/spring-orm/src/main/java/overview.html b/spring-orm/src/main/java/overview.html index 37f532b39ba..67b448a9064 100644 --- a/spring-orm/src/main/java/overview.html +++ b/spring-orm/src/main/java/overview.html @@ -1,7 +1,7 @@

-Spring's O/R Mapping package: supporting Hibernate, JPA, JDO, and iBATIS SQL Maps. +Spring's O/R Mapping package: supporting Hibernate, JPA, and JDO.

\ No newline at end of file diff --git a/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java index 9595d8087e8..4a6a46ba79f 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -37,8 +37,9 @@ import static org.junit.Assert.*; @SuppressWarnings("deprecation") public class OxmNamespaceHandlerTests { - private final ApplicationContext applicationContext = new ClassPathXmlApplicationContext( - "oxmNamespaceHandlerTest.xml", getClass()); + private final ApplicationContext applicationContext = + new ClassPathXmlApplicationContext("oxmNamespaceHandlerTest.xml", getClass()); + @Test public void xmlBeansMarshaller() throws Exception { @@ -85,4 +86,5 @@ public class OxmNamespaceHandlerTests { CastorMarshaller castorMarshaller = applicationContext.getBean("castorMappingLocationMarshaller", CastorMarshaller.class); assertNotNull(castorMarshaller); } -} \ No newline at end of file + +} diff --git a/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java b/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java index c4b2a11ea4d..47e488cf29d 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java @@ -61,7 +61,7 @@ public abstract class TestPropertySourceUtils { /** * The name of the {@link MapPropertySource} created from inlined properties. * @since 4.1.5 - * @see {@link #addInlinedPropertiesToEnvironment(ConfigurableEnvironment, String[])} + * @see #addInlinedPropertiesToEnvironment */ public static final String INLINED_PROPERTIES_PROPERTY_SOURCE_NAME = "Inlined Test Properties"; @@ -224,8 +224,7 @@ public abstract class TestPropertySourceUtils { * @see TestPropertySource#properties * @see #addInlinedPropertiesToEnvironment(ConfigurableEnvironment, String[]) */ - public static void addInlinedPropertiesToEnvironment(ConfigurableApplicationContext context, - String... inlinedProperties) { + public static void addInlinedPropertiesToEnvironment(ConfigurableApplicationContext context, String... inlinedProperties) { Assert.notNull(context, "context must not be null"); Assert.notNull(inlinedProperties, "inlinedProperties must not be null"); addInlinedPropertiesToEnvironment(context.getEnvironment(), inlinedProperties); @@ -252,13 +251,11 @@ public abstract class TestPropertySourceUtils { Assert.notNull(inlinedProperties, "inlinedProperties must not be null"); if (!ObjectUtils.isEmpty(inlinedProperties)) { if (logger.isDebugEnabled()) { - logger.debug("Adding inlined properties to environment: " - + ObjectUtils.nullSafeToString(inlinedProperties)); + logger.debug("Adding inlined properties to environment: " + ObjectUtils.nullSafeToString(inlinedProperties)); } MapPropertySource ps = (MapPropertySource) environment.getPropertySources().get(INLINED_PROPERTIES_PROPERTY_SOURCE_NAME); if (ps == null) { - ps = new MapPropertySource(INLINED_PROPERTIES_PROPERTY_SOURCE_NAME, - new LinkedHashMap()); + ps = new MapPropertySource(INLINED_PROPERTIES_PROPERTY_SOURCE_NAME, new LinkedHashMap()); environment.getPropertySources().addFirst(ps); } ps.getSource().putAll(convertInlinedPropertiesToMap(inlinedProperties)); @@ -285,21 +282,19 @@ public abstract class TestPropertySourceUtils { public static Map convertInlinedPropertiesToMap(String... inlinedProperties) { Assert.notNull(inlinedProperties, "inlinedProperties must not be null"); Map map = new LinkedHashMap(); - Properties props = new Properties(); + for (String pair : inlinedProperties) { if (!StringUtils.hasText(pair)) { continue; } - try { props.load(new StringReader(pair)); } - catch (Exception e) { - throw new IllegalStateException("Failed to load test environment property from [" + pair + "].", e); + catch (Exception ex) { + throw new IllegalStateException("Failed to load test environment property from [" + pair + "]", ex); } - Assert.state(props.size() == 1, "Failed to load exactly one test environment property from [" + pair + "]."); - + Assert.state(props.size() == 1, "Failed to load exactly one test environment property from [" + pair + "]"); for (String name : props.stringPropertyNames()) { map.put(name, props.getProperty(name)); } diff --git a/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java b/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java index 8e3e9a05c8d..e0e1bc0e656 100644 --- a/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java +++ b/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -124,6 +124,7 @@ public class JdbcTestUtils { */ public static int deleteFromTableWhere(JdbcTemplate jdbcTemplate, String tableName, String whereClause, Object... args) { + String sql = "DELETE FROM " + tableName; if (StringUtils.hasText(whereClause)) { sql += " WHERE " + whereClause; @@ -170,6 +171,7 @@ public class JdbcTestUtils { @Deprecated public static void executeSqlScript(JdbcTemplate jdbcTemplate, ResourceLoader resourceLoader, String sqlResourcePath, boolean continueOnError) throws DataAccessException { + Resource resource = resourceLoader.getResource(sqlResourcePath); executeSqlScript(jdbcTemplate, resource, continueOnError); } @@ -197,6 +199,7 @@ public class JdbcTestUtils { @Deprecated public static void executeSqlScript(JdbcTemplate jdbcTemplate, Resource resource, boolean continueOnError) throws DataAccessException { + executeSqlScript(jdbcTemplate, new EncodedResource(resource), continueOnError); } @@ -220,6 +223,7 @@ public class JdbcTestUtils { @Deprecated public static void executeSqlScript(JdbcTemplate jdbcTemplate, EncodedResource resource, boolean continueOnError) throws DataAccessException { + new ResourceDatabasePopulator(continueOnError, false, resource.getEncoding(), resource.getResource()).execute(jdbcTemplate.getDataSource()); } @@ -288,4 +292,5 @@ public class JdbcTestUtils { public static void splitSqlScript(String script, char delim, List statements) { ScriptUtils.splitSqlScript(script, delim, statements); } + } diff --git a/spring-web/src/main/java/org/springframework/http/client/ClientHttpRequestExecution.java b/spring-web/src/main/java/org/springframework/http/client/ClientHttpRequestExecution.java index df6e10c6f0e..2fe64f52874 100644 --- a/spring-web/src/main/java/org/springframework/http/client/ClientHttpRequestExecution.java +++ b/spring-web/src/main/java/org/springframework/http/client/ClientHttpRequestExecution.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2016 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. @@ -23,22 +23,23 @@ import org.springframework.http.HttpRequest; /** * Represents the context of a client-side HTTP request execution. * - *

Used to invoke the next interceptor in the interceptor chain, or - if the calling interceptor is last - execute - * the request itself. + *

Used to invoke the next interceptor in the interceptor chain, + * or - if the calling interceptor is last - execute the request itself. * * @author Arjen Poutsma - * @see ClientHttpRequestInterceptor * @since 3.1 + * @see ClientHttpRequestInterceptor */ public interface ClientHttpRequestExecution { /** - * Execute the request with the given request attributes and body, and return the response. - * + * Execute the request with the given request attributes and body, + * and return the response. * @param request the request, containing method, URI, and headers * @param body the body of the request to execute * @return the response * @throws IOException in case of I/O errors */ ClientHttpResponse execute(HttpRequest request, byte[] body) throws IOException; + } diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java index beee0a4f0f6..12cee3308a2 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java @@ -812,7 +812,7 @@ public class Jackson2ObjectMapperBuilder { return new XmlMapper(new XmlFactory(xmlInputFactory()), module); } - private static final XMLInputFactory xmlInputFactory() { + private static XMLInputFactory xmlInputFactory() { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false); inputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); diff --git a/spring-web/src/main/java/org/springframework/remoting/jaxws/SimpleJaxWsServiceExporter.java b/spring-web/src/main/java/org/springframework/remoting/jaxws/SimpleJaxWsServiceExporter.java index 08c47e614c8..8746786f144 100644 --- a/spring-web/src/main/java/org/springframework/remoting/jaxws/SimpleJaxWsServiceExporter.java +++ b/spring-web/src/main/java/org/springframework/remoting/jaxws/SimpleJaxWsServiceExporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2016 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. @@ -31,9 +31,9 @@ import javax.xml.ws.WebServiceProvider; *

Note that this exporter will only work if the JAX-WS runtime actually * supports publishing with an address argument, i.e. if the JAX-WS runtime * ships an internal HTTP server. This is the case with the JAX-WS runtime - * that's inclued in Sun's JDK 1.6 but not with the standalone JAX-WS 2.1 RI. + * that's included in Sun's JDK 6 but not with the standalone JAX-WS 2.1 RI. * - *

For explicit configuration of JAX-WS endpoints with Sun's JDK 1.6 + *

For explicit configuration of JAX-WS endpoints with Sun's JDK 6 * HTTP server, consider using {@link SimpleHttpServerJaxWsServiceExporter}! * * @author Juergen Hoeller diff --git a/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java b/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java index 94b40ae979f..ea3c0ae844c 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java +++ b/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -70,6 +70,9 @@ import org.springframework.web.multipart.MultipartRequest; */ public class WebRequestDataBinder extends WebDataBinder { + private static final boolean servlet3Parts = ClassUtils.hasMethod(HttpServletRequest.class, "getParts"); + + /** * Create a new WebRequestDataBinder instance, with default object name. * @param target the target object to bind onto (or {@code null} @@ -116,7 +119,7 @@ public class WebRequestDataBinder extends WebDataBinder { if (multipartRequest != null) { bindMultipart(multipartRequest.getMultiFileMap(), mpvs); } - else if (ClassUtils.hasMethod(HttpServletRequest.class, "getParts")) { + else if (servlet3Parts) { HttpServletRequest serlvetRequest = ((NativeWebRequest) request).getNativeRequest(HttpServletRequest.class); new Servlet3MultipartHelper(isBindEmptyMultipartFiles()).bindParts(serlvetRequest, mpvs); } diff --git a/spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java b/spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java index b29397f2140..97a227af112 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java @@ -23,7 +23,6 @@ import java.util.Locale; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java index 4356d14603d..305b639642f 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java @@ -122,7 +122,7 @@ public abstract class MultipartResolutionDelegate { return null; } } - else if (parameter.getNestedParameterType() == servletPartClass) { + else if (servletPartClass == parameter.getNestedParameterType()) { return (isMultipart ? RequestPartResolver.resolvePart(request, name) : null); } else if (isPartCollection(parameter)) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java index 6f8e803674f..e49eeafbfb6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java @@ -93,7 +93,7 @@ public interface HandlerInterceptor { * @throws Exception in case of errors */ boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) - throws Exception; + throws Exception; /** * Intercept the execution of a handler. Called after HandlerAdapter actually @@ -114,7 +114,8 @@ public interface HandlerInterceptor { * (can also be {@code null}) * @throws Exception in case of errors */ - void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) + void postHandle( + HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception; /** @@ -136,7 +137,8 @@ public interface HandlerInterceptor { * @param ex exception thrown on handler execution, if any * @throws Exception in case of errors */ - void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) + void afterCompletion( + HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/LocaleResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/LocaleResolver.java index 80998d0f6e7..2d0f9540229 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/LocaleResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/LocaleResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 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. @@ -51,8 +51,8 @@ import javax.servlet.http.HttpServletResponse; public interface LocaleResolver { /** - * Resolve the current locale via the given request. Can return a default locale as - * fallback in any case. + * Resolve the current locale via the given request. + * Can return a default locale as fallback in any case. * @param request the request to resolve the locale for * @return the current locale (never {@code null}) */ @@ -63,8 +63,8 @@ public interface LocaleResolver { * @param request the request to be used for locale modification * @param response the response to be used for locale modification * @param locale the new locale, or {@code null} to clear the locale - * @throws UnsupportedOperationException if the LocaleResolver implementation does not - * support dynamic changing of the locale + * @throws UnsupportedOperationException if the LocaleResolver + * implementation does not support dynamic changing of the locale */ void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMapping.java index 397c179b039..44376cbd6aa 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2016 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,9 +28,9 @@ import org.springframework.util.StringUtils; * *

This is the default implementation used by the * {@link org.springframework.web.servlet.DispatcherServlet}, along with - * {@link org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping} - * (on Java 5 and higher). Alternatively, {@link SimpleUrlHandlerMapping} allows for - * customizing a handler mapping declaratively. + * {@link org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping}. + * Alternatively, {@link SimpleUrlHandlerMapping} allows for customizing a + * handler mapping declaratively. * *

The mapping is from URL to bean name. Thus an incoming URL "/foo" would map * to a handler named "/foo", or to "/foo /foo2" in case of multiple mappings to diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerInterceptorAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerInterceptorAdapter.java index 602886ba297..b00d46898a1 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerInterceptorAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerInterceptorAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 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. @@ -23,7 +23,7 @@ import org.springframework.web.servlet.AsyncHandlerInterceptor; import org.springframework.web.servlet.ModelAndView; /** - * Abstract adapter class for the HandlerInterceptor interface, + * Abstract adapter class for the {@link AsyncHandlerInterceptor} interface, * for simplified implementation of pre-only/post-only interceptors. * * @author Juergen Hoeller @@ -36,7 +36,8 @@ public abstract class HandlerInterceptorAdapter implements AsyncHandlerIntercept */ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) - throws Exception { + throws Exception { + return true; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/CompletionStageReturnValueHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/CompletionStageReturnValueHandler.java index 7ec8e7c0f92..c3c7b1d0142 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/CompletionStageReturnValueHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/CompletionStageReturnValueHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -34,7 +34,6 @@ import org.springframework.web.method.support.ModelAndViewContainer; * * @author Sebastien Deleuze * @since 4.2 - * * @deprecated as of 4.3 {@link DeferredResultMethodReturnValueHandler} supports * CompletionStage return values via an adapter mechanism. */ diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultMethodReturnValueHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultMethodReturnValueHandler.java index 6361c77ff13..789606dc637 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultMethodReturnValueHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultMethodReturnValueHandler.java @@ -114,6 +114,7 @@ public class DeferredResultMethodReturnValueHandler implements AsyncHandlerMetho } } + /** * Adapter for {@code ListenableFuture} return values. */ @@ -137,6 +138,7 @@ public class DeferredResultMethodReturnValueHandler implements AsyncHandlerMetho } } + /** * Adapter for {@code CompletionStage} return values. */ diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ListenableFutureReturnValueHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ListenableFutureReturnValueHandler.java index 3a3706f06ba..d4a8fe62bc2 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ListenableFutureReturnValueHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ListenableFutureReturnValueHandler.java @@ -31,7 +31,6 @@ import org.springframework.web.method.support.ModelAndViewContainer; * * @author Rossen Stoyanchev * @since 4.1 - * * @deprecated as of 4.3 {@link DeferredResultMethodReturnValueHandler} supports * ListenableFuture return values via an adapter mechanism. */ diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java index 4380246e843..fa884f7a496 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -49,12 +49,11 @@ import org.springframework.util.StringUtils; */ public class CssLinkResourceTransformer extends ResourceTransformerSupport { - private static final Log logger = LogFactory.getLog(CssLinkResourceTransformer.class); - private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); + private static final Log logger = LogFactory.getLog(CssLinkResourceTransformer.class); - private final List linkParsers = new ArrayList(); + private final List linkParsers = new ArrayList(2); public CssLinkResourceTransformer() { @@ -81,7 +80,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport { byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream()); String content = new String(bytes, DEFAULT_CHARSET); - Set infos = new HashSet(5); + Set infos = new HashSet(8); for (CssLinkParser parser : this.linkParsers) { parser.parseLink(content, infos); } @@ -123,17 +122,16 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport { private boolean hasScheme(String link) { int schemeIndex = link.indexOf(":"); - return (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/")) - || link.indexOf("//") == 0; + return (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/")) || link.indexOf("//") == 0; } - protected static interface CssLinkParser { + protected interface CssLinkParser { void parseLink(String content, Set linkInfos); - } + protected static abstract class AbstractCssLinkParser implements CssLinkParser { /** @@ -189,6 +187,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport { } + private static class ImportStatementCssLinkParser extends AbstractCssLinkParser { @Override @@ -208,6 +207,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport { } } + private static class UrlFunctionCssLinkParser extends AbstractCssLinkParser { @Override @@ -229,8 +229,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport { private final int end; - - private CssLinkInfo(int start, int end) { + public CssLinkInfo(int start, int end) { this.start = start; this.end = end; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformer.java index fe941d830bf..de17faf1b5d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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,10 +35,10 @@ public interface ResourceTransformer { * @param request the current request * @param resource the resource to transform * @param transformerChain the chain of remaining transformers to delegate to - * @return the transformed resource, never {@code null} + * @return the transformed resource (never {@code null}) * @throws IOException if the transformation fails */ Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) throws IOException; -} \ No newline at end of file +} diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java index ca2df2ca23f..79d50c93a6d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -54,6 +54,7 @@ public class UriTemplateServletAnnotationControllerTests { private DispatcherServlet servlet; + @Test public void simple() throws Exception { initServlet(SimpleUriTemplateController.class); @@ -318,8 +319,7 @@ public class UriTemplateServletAnnotationControllerTests { assertEquals("test-42", response.getContentAsString()); } - // SPR-6640 - @Test + @Test // SPR-6640 public void menuTree() throws Exception { initServlet(MenuTreeController.class); @@ -329,8 +329,7 @@ public class UriTemplateServletAnnotationControllerTests { assertEquals("M5", response.getContentAsString()); } - // SPR-6876 - @Test + @Test // SPR-6876 public void variableNames() throws Exception { initServlet(VariableNamesController.class); @@ -345,8 +344,7 @@ public class UriTemplateServletAnnotationControllerTests { assertEquals("bar-bar", response.getContentAsString()); } - // SPR-8543 - @Test + @Test // SPR-8543 public void variableNamesWithUrlExtension() throws Exception { initServlet(VariableNamesController.class); @@ -356,8 +354,7 @@ public class UriTemplateServletAnnotationControllerTests { assertEquals("foo-foo", response.getContentAsString()); } - // SPR-9333 - @Test + @Test // SPR-9333 @SuppressWarnings("serial") public void suppressDefaultSuffixPattern() throws Exception { servlet = new DispatcherServlet() { @@ -381,8 +378,7 @@ public class UriTemplateServletAnnotationControllerTests { assertEquals("foo-jsmith@mail.com", response.getContentAsString()); } - // SPR-6906 - @Test + @Test // SPR-6906 @SuppressWarnings("serial") public void controllerClassName() throws Exception { servlet = new DispatcherServlet() { @@ -416,8 +412,7 @@ public class UriTemplateServletAnnotationControllerTests { assertEquals("plain-bar", response.getContentAsString()); } - // SPR-6978 - @Test + @Test // SPR-6978 public void doIt() throws Exception { initServlet(Spr6978Controller.class); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java index 2dbd8157064..faa32b6911d 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.concurrent.Callable; - import javax.websocket.ClientEndpointConfig; import javax.websocket.ClientEndpointConfig.Configurator; import javax.websocket.ContainerProvider; @@ -51,7 +50,6 @@ import org.springframework.web.socket.adapter.standard.StandardWebSocketSession; import org.springframework.web.socket.adapter.standard.WebSocketToStandardExtensionAdapter; import org.springframework.web.socket.client.AbstractWebSocketClient; - /** * A WebSocketClient based on standard Java WebSocket API. * diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java index bbe55538fcf..048cd3a03b8 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -67,8 +67,8 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry { org.springframework.messaging.simp.user.UserSessionRegistry userSessionRegistry, TaskScheduler defaultSockJsTaskScheduler) { - Assert.notNull(webSocketHandler, "'webSocketHandler' is required "); - Assert.notNull(transportRegistration, "'transportRegistration' is required"); + Assert.notNull(webSocketHandler, "WebSocketHandler is required "); + Assert.notNull(transportRegistration, "WebSocketTransportRegistration is required"); this.webSocketHandler = webSocketHandler; this.subProtocolWebSocketHandler = unwrapSubProtocolWebSocketHandler(webSocketHandler); @@ -87,19 +87,17 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry { this.stompHandler.setMessageSizeLimit(transportRegistration.getMessageSizeLimit()); } - this.sockJsScheduler = defaultSockJsTaskScheduler; } private static SubProtocolWebSocketHandler unwrapSubProtocolWebSocketHandler(WebSocketHandler handler) { WebSocketHandler actual = WebSocketHandlerDecorator.unwrap(handler); - Assert.isInstanceOf(SubProtocolWebSocketHandler.class, actual, "No SubProtocolWebSocketHandler in " + handler); + if (!(actual instanceof SubProtocolWebSocketHandler)) { + throw new IllegalArgumentException("No SubProtocolWebSocketHandler in " + handler); + }; return (SubProtocolWebSocketHandler) actual; } - protected void setApplicationContext(ApplicationContext applicationContext) { - this.stompHandler.setApplicationEventPublisher(applicationContext); - } @Override public StompWebSocketEndpointRegistration addEndpoint(String... paths) { @@ -144,6 +142,11 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry { return this; } + protected void setApplicationContext(ApplicationContext applicationContext) { + this.stompHandler.setApplicationEventPublisher(applicationContext); + } + + /** * Return a handler mapping with the mapped ViewControllers; or {@code null} * in case of no registrations. diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java index 0e6a31df0d0..35886efc724 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -193,7 +193,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda private static final Method registerMethod; - private static final Method unRegisterMethod; + private static final Method unregisterMethod; static { try { @@ -204,7 +204,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda throw new IllegalStateException("Expected TyrusEndpointWrapper constructor with 9 or 10 arguments"); } registerMethod = TyrusWebSocketEngine.class.getDeclaredMethod("register", TyrusEndpointWrapper.class); - unRegisterMethod = TyrusWebSocketEngine.class.getDeclaredMethod("unregister", TyrusEndpointWrapper.class); + unregisterMethod = TyrusWebSocketEngine.class.getDeclaredMethod("unregister", TyrusEndpointWrapper.class); ReflectionUtils.makeAccessible(registerMethod); } catch (Exception ex) { @@ -259,7 +259,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda @Override public void unregister(TyrusWebSocketEngine engine, Object endpoint) { try { - unRegisterMethod.invoke(engine, endpoint); + unregisterMethod.invoke(engine, endpoint); } catch (Exception ex) { throw new HandshakeFailureException("Failed to unregister " + endpoint, ex); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/WebLogicRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/WebLogicRequestUpgradeStrategy.java index c16d747a802..58b294077fe 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/WebLogicRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/WebLogicRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -60,7 +60,6 @@ public class WebLogicRequestUpgradeStrategy extends AbstractTyrusRequestUpgradeS private static final WebLogicServletWriterHelper servletWriterHelper = new WebLogicServletWriterHelper(); private static final Connection.CloseListener noOpCloseListener = new Connection.CloseListener() { - @Override public void close(CloseReason reason) { } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractXhrTransport.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractXhrTransport.java index 7b7f51d22d7..2d0fac299e9 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractXhrTransport.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractXhrTransport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -54,6 +54,7 @@ public abstract class AbstractXhrTransport implements XhrTransport { PRELUDE = new String(bytes, SockJsFrame.CHARSET); } + protected Log logger = LogFactory.getLog(getClass()); private boolean xhrStreamingDisabled; @@ -137,6 +138,7 @@ public abstract class AbstractXhrTransport implements XhrTransport { URI receiveUrl, HttpHeaders handshakeHeaders, XhrClientSockJsSession session, SettableListenableFuture connectFuture); + // InfoReceiver methods @Override @@ -165,6 +167,7 @@ public abstract class AbstractXhrTransport implements XhrTransport { protected abstract ResponseEntity executeInfoRequestInternal(URI infoUrl, HttpHeaders headers); + // XhrTransport methods @Override @@ -184,8 +187,8 @@ public abstract class AbstractXhrTransport implements XhrTransport { } } - protected abstract ResponseEntity executeSendRequestInternal(URI url, - HttpHeaders headers, TextMessage message); + protected abstract ResponseEntity executeSendRequestInternal( + URI url, HttpHeaders headers, TextMessage message); @Override diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/PollingSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/PollingSockJsSession.java index e3cb44882ee..d8066c2e06d 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/PollingSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/PollingSockJsSession.java @@ -35,7 +35,6 @@ import org.springframework.web.socket.sockjs.transport.SockJsServiceConfig; */ public class PollingSockJsSession extends AbstractHttpSockJsSession { - public PollingSockJsSession(String sessionId, SockJsServiceConfig config, WebSocketHandler wsHandler, Map attributes) { diff --git a/spring-websocket/src/main/resources/org/springframework/web/socket/config/spring-websocket.gif b/spring-websocket/src/main/resources/org/springframework/web/socket/config/spring-websocket.gif new file mode 100644 index 00000000000..9e4c800e48d Binary files /dev/null and b/spring-websocket/src/main/resources/org/springframework/web/socket/config/spring-websocket.gif differ diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java index 7067ef25db0..2309f74f853 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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 java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -48,9 +47,7 @@ import org.springframework.web.socket.server.support.DefaultHandshakeHandler; */ public abstract class AbstractWebSocketIntegrationTests { - protected Log logger = LogFactory.getLog(getClass()); - - private static Map, Class> upgradeStrategyConfigTypes = new HashMap, Class>(); + private static Map, Class> upgradeStrategyConfigTypes = new HashMap<>(); static { upgradeStrategyConfigTypes.put(JettyWebSocketTestServer.class, JettyUpgradeStrategyConfig.class); @@ -58,6 +55,7 @@ public abstract class AbstractWebSocketIntegrationTests { upgradeStrategyConfigTypes.put(UndertowTestServer.class, UndertowUpgradeStrategyConfig.class); } + @Rule public final TestName testName = new TestName(); @@ -67,12 +65,13 @@ public abstract class AbstractWebSocketIntegrationTests { @Parameter(1) public WebSocketClient webSocketClient; + protected final Log logger = LogFactory.getLog(getClass()); + protected AnnotationConfigWebApplicationContext wac; @Before public void setup() throws Exception { - logger.debug("Setting up '" + this.testName.getMethodName() + "', client=" + this.webSocketClient.getClass().getSimpleName() + ", server=" + this.server.getClass().getSimpleName()); @@ -155,6 +154,7 @@ public abstract class AbstractWebSocketIntegrationTests { } } + @Configuration static class TomcatUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig { @@ -164,6 +164,7 @@ public abstract class AbstractWebSocketIntegrationTests { } } + @Configuration static class UndertowUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig { diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketHandshakeTests.java similarity index 95% rename from spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java rename to spring-websocket/src/test/java/org/springframework/web/socket/WebSocketHandshakeTests.java index 1d86998daed..813b7b5fbf8 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketHandshakeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -46,9 +46,10 @@ import static org.junit.Assert.*; * Client and server-side WebSocket integration tests. * * @author Rossen Stoyanchev + * @author Juergen Hoeller */ @RunWith(Parameterized.class) -public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { +public class WebSocketHandshakeTests extends AbstractWebSocketIntegrationTests { @Parameters(name = "server [{0}], client [{1}]") public static Iterable arguments() { @@ -62,7 +63,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest @Override protected Class[] getAnnotatedConfigClasses() { - return new Class[] { TestConfig.class }; + return new Class[] {TestConfig.class}; } @Test @@ -75,11 +76,8 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest session.close(); } - // SPR-12727 - - @Test + @Test // SPR-12727 public void unsolicitedPongWithEmptyPayload() throws Exception { - String url = getWsBaseUrl() + "/ws"; WebSocketSession session = this.webSocketClient.doHandshake(new AbstractWebSocketHandler() {}, url).get(); @@ -126,7 +124,6 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest private Throwable transportError; - public void setWaitMessageCount(int waitMessageCount) { this.waitMessageCount = waitMessageCount; }