diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java index 14ad6c67a91..64ead7b69b3 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2017 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. @@ -22,7 +22,6 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.PointcutAdvisor; import org.springframework.core.Ordered; import org.springframework.util.Assert; -import org.springframework.util.ObjectUtils; /** * AspectJPointcutAdvisor that adapts an {@link AbstractAspectJAdvice} @@ -51,11 +50,11 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered { this.pointcut = advice.buildSafePointcut(); } + public void setOrder(int order) { this.order = order; } - @Override public boolean isPerInstance() { return true; @@ -91,12 +90,12 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered { return false; } AspectJPointcutAdvisor otherAdvisor = (AspectJPointcutAdvisor) other; - return (ObjectUtils.nullSafeEquals(this.advice, otherAdvisor.advice)); + return this.advice.equals(otherAdvisor.advice); } @Override public int hashCode() { - return AspectJPointcutAdvisor.class.hashCode(); + return AspectJPointcutAdvisor.class.hashCode() * 29 + this.advice.hashCode(); } } diff --git a/spring-aop/src/main/java/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.java b/spring-aop/src/main/java/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.java index 64cc673bab7..22881292f60 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2017 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,8 +21,8 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.core.Ordered; +import org.springframework.util.Assert; import org.springframework.util.ClassUtils; -import org.springframework.util.StringUtils; /** * Implementation of {@link AspectInstanceFactory} that locates the aspect from the @@ -50,9 +50,7 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; - if (!StringUtils.hasText(this.aspectBeanName)) { - throw new IllegalArgumentException("'aspectBeanName' is required"); - } + Assert.notNull(this.aspectBeanName, "'aspectBeanName' is required"); } diff --git a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyUtils.java b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyUtils.java index f6213a7d3c5..9db73d062dc 100644 --- a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -89,7 +89,7 @@ public abstract class ScopedProxyUtils { } /** - * Generates the bean name that is used within the scoped proxy to reference the target bean. + * Generate the bean name that is used within the scoped proxy to reference the target bean. * @param originalBeanName the original name of bean * @return the generated bean to be used to reference the target bean */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java index 2b88d827657..e4b3b45b129 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2017 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. @@ -76,8 +76,7 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com List innerBeans = new ArrayList(); List references = new ArrayList(); PropertyValues propertyValues = beanDefinition.getPropertyValues(); - for (int i = 0; i < propertyValues.getPropertyValues().length; i++) { - PropertyValue propertyValue = propertyValues.getPropertyValues()[i]; + for (PropertyValue propertyValue : propertyValues.getPropertyValues()) { Object value = propertyValue.getValue(); if (value instanceof BeanDefinitionHolder) { innerBeans.add(((BeanDefinitionHolder) value).getBeanDefinition()); diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheResolver.java b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheResolver.java index 0ddb97460ac..9ee27e000ec 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheResolver.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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,7 +54,7 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi } /** - * Return the {@link CacheManager} that this instance use. + * Return the {@link CacheManager} that this instance uses. */ public CacheManager getCacheManager() { return this.cacheManager; @@ -62,7 +62,7 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi @Override public void afterPropertiesSet() { - Assert.notNull(this.cacheManager, "CacheManager must not be null"); + Assert.notNull(this.cacheManager, "CacheManager is required"); } @@ -75,7 +75,7 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi else { Collection result = new ArrayList(); for (String cacheName : cacheNames) { - Cache cache = this.cacheManager.getCache(cacheName); + Cache cache = getCacheManager().getCache(cacheName); if (cache == null) { throw new IllegalArgumentException("Cannot find cache named '" + cacheName + "' for " + context.getOperation()); @@ -91,7 +91,7 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi *

It is acceptable to return {@code null} to indicate that no cache could * be resolved for this invocation. * @param context the context of the particular invocation - * @return the cache name(s) to resolve or {@code null} if no cache should be resolved + * @return the cache name(s) to resolve, or {@code null} if no cache should be resolved */ protected abstract Collection getCacheNames(CacheOperationInvocationContext context); diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java b/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java index f75fd2e8c16..63fe1df7c4e 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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,7 +16,6 @@ package org.springframework.cache.interceptor; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -34,13 +33,15 @@ public class NamedCacheResolver extends AbstractCacheResolver { private Collection cacheNames; + + public NamedCacheResolver() { + } + public NamedCacheResolver(CacheManager cacheManager, String... cacheNames) { super(cacheManager); this.cacheNames = new ArrayList(Arrays.asList(cacheNames)); } - public NamedCacheResolver() { - } /** * Set the cache name(s) that this resolver should use. diff --git a/spring-context/src/main/java/org/springframework/cache/support/SimpleCacheManager.java b/spring-context/src/main/java/org/springframework/cache/support/SimpleCacheManager.java index 5c373a2b70b..23dba09e038 100644 --- a/spring-context/src/main/java/org/springframework/cache/support/SimpleCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/support/SimpleCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2017 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. @@ -17,6 +17,7 @@ package org.springframework.cache.support; import java.util.Collection; +import java.util.Collections; import org.springframework.cache.Cache; @@ -29,7 +30,7 @@ import org.springframework.cache.Cache; */ public class SimpleCacheManager extends AbstractCacheManager { - private Collection caches; + private Collection caches = Collections.emptySet(); /** diff --git a/spring-context/src/main/java/org/springframework/jndi/TypeMismatchNamingException.java b/spring-context/src/main/java/org/springframework/jndi/TypeMismatchNamingException.java index c82108a9124..0bf561d3e8a 100644 --- a/spring-context/src/main/java/org/springframework/jndi/TypeMismatchNamingException.java +++ b/spring-context/src/main/java/org/springframework/jndi/TypeMismatchNamingException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2017 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,7 +51,9 @@ public class TypeMismatchNamingException extends NamingException { /** * Construct a new TypeMismatchNamingException. * @param explanation the explanation text + * @deprecated as of Spring Framework 4.3.10 */ + @Deprecated public TypeMismatchNamingException(String explanation) { super(explanation); } diff --git a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java index 179d061ecc6..05e6f604f8e 100644 --- a/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2017 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,8 +49,8 @@ public class ScopedProxyTests { private static final ClassPathResource OVERRIDE_CONTEXT = new ClassPathResource(CLASSNAME + "-override.xml", CLASS); private static final ClassPathResource TESTBEAN_CONTEXT = new ClassPathResource(CLASSNAME + "-testbean.xml", CLASS); - /* SPR-2108 */ - @Test + + @Test // SPR-2108 public void testProxyAssignable() throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT); diff --git a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml index 768e429c2f6..41fcd3a1b04 100644 --- a/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml +++ b/spring-context/src/test/resources/org/springframework/aop/scope/ScopedProxyTests-override.xml @@ -6,16 +6,16 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> - - - + + + - - - - - - - + + + + + + + diff --git a/spring-core/src/main/java/org/springframework/core/io/PathResource.java b/spring-core/src/main/java/org/springframework/core/io/PathResource.java index af046049c3c..f046275136e 100644 --- a/spring-core/src/main/java/org/springframework/core/io/PathResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/PathResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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,7 @@ public class PathResource extends AbstractResource implements WritableResource { * Create a new PathResource from a Path handle. *

Note: Unlike {@link FileSystemResource}, when building relative resources * via {@link #createRelative}, the relative path will be built underneath - * the given root: - * e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"! + * the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"! * @param path a Path handle */ public PathResource(Path path) { @@ -64,8 +63,7 @@ public class PathResource extends AbstractResource implements WritableResource { * Create a new PathResource from a Path handle. *

Note: Unlike {@link FileSystemResource}, when building relative resources * via {@link #createRelative}, the relative path will be built underneath - * the given root: - * e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"! + * the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"! * @param path a path * @see java.nio.file.Paths#get(String, String...) */ @@ -78,8 +76,7 @@ public class PathResource extends AbstractResource implements WritableResource { * Create a new PathResource from a Path handle. *

Note: Unlike {@link FileSystemResource}, when building relative resources * via {@link #createRelative}, the relative path will be built underneath - * the given root: - * e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"! + * the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"! * @see java.nio.file.Paths#get(URI) * @param uri a path URI */ @@ -184,7 +181,7 @@ public class PathResource extends AbstractResource implements WritableResource { catch (UnsupportedOperationException ex) { // Only paths on the default file system can be converted to a File: // Do exception translation for cases where conversion is not possible. - throw new FileNotFoundException(this.path + " cannot be resolved to " + "absolute file path"); + throw new FileNotFoundException(this.path + " cannot be resolved to absolute file path"); } } @@ -204,11 +201,11 @@ public class PathResource extends AbstractResource implements WritableResource { public long lastModified() throws IOException { // We can not use the superclass method since it uses conversion to a File and // only a Path on the default file system can be converted to a File... - return Files.getLastModifiedTime(path).toMillis(); + return Files.getLastModifiedTime(this.path).toMillis(); } /** - * This implementation creates a FileResource, applying the given path + * This implementation creates a PathResource, applying the given path * relative to the path of the underlying file of this resource descriptor. * @see java.nio.file.Path#resolve(String) */ diff --git a/spring-core/src/main/java/org/springframework/util/xml/StaxResult.java b/spring-core/src/main/java/org/springframework/util/xml/StaxResult.java index a8d9bfa26f6..57c17509b0a 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/StaxResult.java +++ b/spring-core/src/main/java/org/springframework/util/xml/StaxResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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,17 +51,6 @@ class StaxResult extends SAXResult { private XMLStreamWriter streamWriter; - /** - * Construct a new instance of the {@code StaxResult} with the specified {@code XMLStreamWriter}. - * @param streamWriter the {@code XMLStreamWriter} to write to - */ - public StaxResult(XMLStreamWriter streamWriter) { - StaxStreamHandler handler = new StaxStreamHandler(streamWriter); - super.setHandler(handler); - super.setLexicalHandler(handler); - this.streamWriter = streamWriter; - } - /** * Construct a new instance of the {@code StaxResult} with the specified {@code XMLEventWriter}. * @param eventWriter the {@code XMLEventWriter} to write to @@ -73,10 +62,22 @@ class StaxResult extends SAXResult { this.eventWriter = eventWriter; } + /** + * Construct a new instance of the {@code StaxResult} with the specified {@code XMLStreamWriter}. + * @param streamWriter the {@code XMLStreamWriter} to write to + */ + public StaxResult(XMLStreamWriter streamWriter) { + StaxStreamHandler handler = new StaxStreamHandler(streamWriter); + super.setHandler(handler); + super.setLexicalHandler(handler); + this.streamWriter = streamWriter; + } + /** - * Return the {@code XMLEventWriter} used by this {@code StaxResult}. If this {@code StaxResult} - * was created with an {@code XMLStreamWriter}, the result will be {@code null}. + * Return the {@code XMLEventWriter} used by this {@code StaxResult}. + *

If this {@code StaxResult} was created with an {@code XMLStreamWriter}, + * the result will be {@code null}. * @return the StAX event writer used by this result * @see #StaxResult(javax.xml.stream.XMLEventWriter) */ @@ -85,8 +86,9 @@ class StaxResult extends SAXResult { } /** - * Return the {@code XMLStreamWriter} used by this {@code StaxResult}. If this {@code StaxResult} - * was created with an {@code XMLEventConsumer}, the result will be {@code null}. + * Return the {@code XMLStreamWriter} used by this {@code StaxResult}. + *

If this {@code StaxResult} was created with an {@code XMLEventConsumer}, + * the result will be {@code null}. * @return the StAX stream writer used by this result * @see #StaxResult(javax.xml.stream.XMLStreamWriter) */ diff --git a/spring-core/src/main/java/org/springframework/util/xml/StaxSource.java b/spring-core/src/main/java/org/springframework/util/xml/StaxSource.java index 5706a4317ed..569dba9d220 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/StaxSource.java +++ b/spring-core/src/main/java/org/springframework/util/xml/StaxSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2017 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. @@ -50,18 +50,6 @@ class StaxSource extends SAXSource { private XMLStreamReader streamReader; - /** - * Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}. - * The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or - * {@code XMLStreamConstants.START_ELEMENT} state. - * @param streamReader the {@code XMLStreamReader} to read from - * @throws IllegalStateException if the reader is not at the start of a document or element - */ - StaxSource(XMLStreamReader streamReader) { - super(new StaxStreamXMLReader(streamReader), new InputSource()); - this.streamReader = streamReader; - } - /** * Construct a new instance of the {@code StaxSource} with the specified {@code XMLEventReader}. * The supplied event reader must be in {@code XMLStreamConstants.START_DOCUMENT} or @@ -74,10 +62,23 @@ class StaxSource extends SAXSource { this.eventReader = eventReader; } + /** + * Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}. + * The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or + * {@code XMLStreamConstants.START_ELEMENT} state. + * @param streamReader the {@code XMLStreamReader} to read from + * @throws IllegalStateException if the reader is not at the start of a document or element + */ + StaxSource(XMLStreamReader streamReader) { + super(new StaxStreamXMLReader(streamReader), new InputSource()); + this.streamReader = streamReader; + } + /** - * Return the {@code XMLEventReader} used by this {@code StaxSource}. If this {@code StaxSource} - * was created with an {@code XMLStreamReader}, the result will be {@code null}. + * Return the {@code XMLEventReader} used by this {@code StaxSource}. + *

If this {@code StaxSource} was created with an {@code XMLStreamReader}, + * the result will be {@code null}. * @return the StAX event reader used by this source * @see StaxSource#StaxSource(javax.xml.stream.XMLEventReader) */ @@ -86,8 +87,9 @@ class StaxSource extends SAXSource { } /** - * Return the {@code XMLStreamReader} used by this {@code StaxSource}. If this {@code StaxSource} - * was created with an {@code XMLEventReader}, the result will be {@code null}. + * Return the {@code XMLStreamReader} used by this {@code StaxSource}. + *

If this {@code StaxSource} was created with an {@code XMLEventReader}, + * the result will be {@code null}. * @return the StAX event reader used by this source * @see StaxSource#StaxSource(javax.xml.stream.XMLEventReader) */ diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java index e5559167838..273a0c1bd62 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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 org.springframework.expression.spel.SpelEvaluationException; import org.springframework.expression.spel.SpelMessage; import org.springframework.expression.spel.support.BooleanTypedValue; - /** * The operator 'instanceof' checks if an object is of the class specified in the right * hand operand, in the same way that {@code instanceof} does in Java. @@ -38,6 +37,7 @@ public class OperatorInstanceof extends Operator { private Class type; + public OperatorInstanceof(int pos, SpelNodeImpl... operands) { super("instanceof", pos, operands); } @@ -47,8 +47,8 @@ public class OperatorInstanceof extends Operator { * Compare the left operand to see it is an instance of the type specified as the * right operand. The right operand must be a class. * @param state the expression state - * @return true if the left operand is an instanceof of the right operand, otherwise - * false + * @return {@code true} if the left operand is an instanceof of the right operand, + * otherwise {@code false} * @throws EvaluationException if there is a problem evaluating the expression */ @Override @@ -58,7 +58,7 @@ public class OperatorInstanceof extends Operator { TypedValue right = rightOperand.getValueInternal(state); Object leftValue = left.getValue(); Object rightValue = right.getValue(); - BooleanTypedValue result = null; + BooleanTypedValue result; if (rightValue == null || !(rightValue instanceof Class)) { throw new SpelEvaluationException(getRightOperand().getStartPosition(), SpelMessage.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND, @@ -96,7 +96,7 @@ public class OperatorInstanceof extends Operator { mv.visitInsn(ICONST_0); // value of false } else { - mv.visitTypeInsn(INSTANCEOF,Type.getInternalName(this.type)); + mv.visitTypeInsn(INSTANCEOF, Type.getInternalName(this.type)); } cf.pushDescriptor(this.exitTypeDescriptor); } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java index 11bf870bad5..ad25bc42231 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -38,11 +38,11 @@ public class TypeReference extends SpelNodeImpl { public TypeReference(int pos, SpelNodeImpl qualifiedId) { - this(pos,qualifiedId,0); + this(pos, qualifiedId, 0); } public TypeReference(int pos, SpelNodeImpl qualifiedId, int dims) { - super(pos,qualifiedId); + super(pos, qualifiedId); this.dimensions = dims; } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/RowCountCallbackHandler.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/RowCountCallbackHandler.java index 3211924855f..942abde4406 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/RowCountCallbackHandler.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/RowCountCallbackHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2017 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,21 +23,22 @@ import java.sql.SQLException; import org.springframework.jdbc.support.JdbcUtils; /** - * Implementation of RowCallbackHandler. Convenient superclass for callback handlers. - * An instance can only be used once. + * Implementation of {@link RowCallbackHandler}. An instance can only be used once. * *

We can either use this on its own (for example, in a test case, to ensure - * that our result sets have valid dimensions), or use it as a superclass - * for callback handlers that actually do something, and will benefit - * from the dimension information it provides. + * that our result sets have valid dimensions), or use it as a superclass for + * callback handlers that actually do something, and will benefit from the + * dimension information it provides. * - *

A usage example with JdbcTemplate: + *

A usage example with {@link JdbcTemplate}: * - *

JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);  // reusable object
+ * 
+ * JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);  // reusable object
  *
  * RowCountCallbackHandler countCallback = new RowCountCallbackHandler();  // not reusable
  * jdbcTemplate.query("select * from user", countCallback);
- * int rowCount = countCallback.getRowCount();
+ * int rowCount = countCallback.getRowCount(); + *
* * @author Rod Johnson * @since May 3, 2001 @@ -63,7 +64,6 @@ public class RowCountCallbackHandler implements RowCallbackHandler { /** - * Implementation of ResultSetCallbackHandler. * Work out column size if this is the first row, otherwise just count rows. *

Subclasses can perform custom extraction or processing * by overriding the {@code processRow(ResultSet, int)} method. @@ -103,7 +103,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler { * Indexed from 0 to n-1. */ public final int[] getColumnTypes() { - return columnTypes; + return this.columnTypes; } /** @@ -113,7 +113,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler { * Indexed from 0 to n-1. */ public final String[] getColumnNames() { - return columnNames; + return this.columnNames; } /** @@ -122,7 +122,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler { * @return the number of rows in this ResultSet */ public final int getRowCount() { - return rowCount; + return this.rowCount; } /** @@ -132,7 +132,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler { * @return the number of columns in this result set */ public final int getColumnCount() { - return columnCount; + return this.columnCount; } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java index 0a2e6d63998..818f525ba7c 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 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. @@ -47,13 +47,13 @@ public class TableMetaDataContext { /** Logger available to subclasses */ protected final Log logger = LogFactory.getLog(getClass()); - /** name of table for this context **/ + /** Name of table for this context */ private String tableName; - /** name of catalog for this context **/ + /** Name of catalog for this context */ private String catalogName; - /** name of schema for this context **/ + /** Name of schema for this context */ private String schemaName; /** List of columns objects to be used in this context */ @@ -153,40 +153,6 @@ public class TableMetaDataContext { return this.tableColumns; } - /** - * Does this database support the JDBC 3.0 feature of retrieving generated keys - * {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}? - */ - public boolean isGetGeneratedKeysSupported() { - return this.metaDataProvider.isGetGeneratedKeysSupported(); - } - - /** - * Does this database support simple query to retrieve generated keys - * when the JDBC 3.0 feature is not supported. - * {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}? - */ - public boolean isGetGeneratedKeysSimulated() { - return this.metaDataProvider.isGetGeneratedKeysSimulated(); - } - - /** - * Does this database support simple query to retrieve generated keys - * when the JDBC 3.0 feature is not supported. - * {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}? - */ - public String getSimulationQueryForGetGeneratedKey(String tableName, String keyColumnName) { - return this.metaDataProvider.getSimpleQueryForGetGeneratedKey(tableName, keyColumnName); - } - - /** - * Is a column name String array for retrieving generated keys supported? - * {@link java.sql.Connection#createStruct(String, Object[])}? - */ - public boolean isGeneratedKeysColumnNameArraySupported() { - return this.metaDataProvider.isGeneratedKeysColumnNameArraySupported(); - } - /** * Set {@link NativeJdbcExtractor} to be used to retrieve the native connection. */ @@ -224,7 +190,7 @@ public class TableMetaDataContext { keys.add(key.toUpperCase()); } List columns = new ArrayList(); - for (TableParameterMetaData meta : metaDataProvider.getTableParameterMetaData()) { + for (TableParameterMetaData meta : this.metaDataProvider.getTableParameterMetaData()) { if (!keys.contains(meta.getParameterName().toUpperCase())) { columns.add(meta.getParameterName()); } @@ -368,4 +334,39 @@ public class TableMetaDataContext { return types; } + + /** + * Does this database support the JDBC 3.0 feature of retrieving generated keys + * {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}? + */ + public boolean isGetGeneratedKeysSupported() { + return this.metaDataProvider.isGetGeneratedKeysSupported(); + } + + /** + * Does this database support simple query to retrieve generated keys + * when the JDBC 3.0 feature is not supported. + * {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}? + */ + public boolean isGetGeneratedKeysSimulated() { + return this.metaDataProvider.isGetGeneratedKeysSimulated(); + } + + /** + * Does this database support simple query to retrieve generated keys + * when the JDBC 3.0 feature is not supported. + * {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}? + */ + public String getSimulationQueryForGetGeneratedKey(String tableName, String keyColumnName) { + return this.metaDataProvider.getSimpleQueryForGetGeneratedKey(tableName, keyColumnName); + } + + /** + * Is a column name String array for retrieving generated keys supported? + * {@link java.sql.Connection#createStruct(String, Object[])}? + */ + public boolean isGeneratedKeysColumnNameArraySupported() { + return this.metaDataProvider.isGeneratedKeysColumnNameArraySupported(); + } + } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/SimpleDriverDataSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/SimpleDriverDataSource.java index 73433728d8a..505917fae6f 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/SimpleDriverDataSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/SimpleDriverDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 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,12 +34,12 @@ import org.springframework.util.Assert; * connection pool, implementing the same standard interface, but creating new * Connections on every call. * - *

In a J2EE container, it is recommended to use a JNDI DataSource provided by + *

In a Java EE container, it is recommended to use a JNDI DataSource provided by * the container. Such a DataSource can be exposed as a DataSource bean in a Spring * ApplicationContext via {@link org.springframework.jndi.JndiObjectFactoryBean}, * for seamless switching to and from a local DataSource bean like this class. * - *

If you need a "real" connection pool outside of a J2EE container, consider + *

If you need a "real" connection pool outside of a Java EE container, consider * Apache Commons DBCP * or C3P0. * Commons DBCP's BasicDataSource and C3P0's ComboPooledDataSource are full 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 19a9ffc041a..928297cb622 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-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -77,10 +77,10 @@ import org.springframework.util.Assert; public class TransactionAwareConnectionFactoryProxy implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory { - private boolean synchedLocalTransactionAllowed = false; - private ConnectionFactory targetConnectionFactory; + private boolean synchedLocalTransactionAllowed = false; + /** * Create a new TransactionAwareConnectionFactoryProxy. diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/IdTimestampMessageHeaderInitializer.java b/spring-messaging/src/main/java/org/springframework/messaging/support/IdTimestampMessageHeaderInitializer.java index b21d7d9776d..3a32c5b54c5 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/IdTimestampMessageHeaderInitializer.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/IdTimestampMessageHeaderInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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,20 +40,12 @@ public class IdTimestampMessageHeaderInitializer implements MessageHeaderInitial * instances with. *

By default this property is set to {@code null} in which case the default * IdGenerator of {@link org.springframework.messaging.MessageHeaders} is used. - *

To have no id's generated at all, see {@link #setDisableIdGeneration()}. + *

To have no ids generated at all, see {@link #setDisableIdGeneration()}. */ public void setIdGenerator(IdGenerator idGenerator) { this.idGenerator = idGenerator; } - /** - * A shortcut for calling {@link #setIdGenerator(org.springframework.util.IdGenerator)} - * with an id generation strategy to disable id generation completely. - */ - public void setDisableIdGeneration() { - this.idGenerator = ID_VALUE_NONE_GENERATOR; - } - /** * Return the configured {@code IdGenerator}, if any. */ @@ -61,6 +53,14 @@ public class IdTimestampMessageHeaderInitializer implements MessageHeaderInitial return this.idGenerator; } + /** + * A shortcut for calling {@link #setIdGenerator} with an id generation strategy + * to disable id generation completely. + */ + public void setDisableIdGeneration() { + this.idGenerator = ID_VALUE_NONE_GENERATOR; + } + /** * Whether to enable the automatic addition of the * {@link org.springframework.messaging.MessageHeaders#TIMESTAMP} header on diff --git a/spring-tx/src/main/java/org/springframework/jca/cci/core/support/CommAreaRecord.java b/spring-tx/src/main/java/org/springframework/jca/cci/core/support/CommAreaRecord.java index a26a7756d19..cc16592e452 100644 --- a/spring-tx/src/main/java/org/springframework/jca/cci/core/support/CommAreaRecord.java +++ b/spring-tx/src/main/java/org/springframework/jca/cci/core/support/CommAreaRecord.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2017 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,22 +60,22 @@ public class CommAreaRecord implements Record, Streamable { @Override public void setRecordName(String recordName) { - this.recordName=recordName; + this.recordName = recordName; } @Override public String getRecordName() { - return recordName; + return this.recordName; } @Override public void setRecordShortDescription(String recordShortDescription) { - this.recordShortDescription=recordShortDescription; + this.recordShortDescription = recordShortDescription; } @Override public String getRecordShortDescription() { - return recordShortDescription; + return this.recordShortDescription; } diff --git a/spring-web/src/main/java/org/springframework/http/client/support/AsyncHttpAccessor.java b/spring-web/src/main/java/org/springframework/http/client/support/AsyncHttpAccessor.java index 00762139eaf..035122a14be 100644 --- a/spring-web/src/main/java/org/springframework/http/client/support/AsyncHttpAccessor.java +++ b/spring-web/src/main/java/org/springframework/http/client/support/AsyncHttpAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2017 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,12 +46,13 @@ public class AsyncHttpAccessor { private AsyncClientHttpRequestFactory asyncRequestFactory; + /** * Set the request factory that this accessor uses for obtaining {@link * org.springframework.http.client.ClientHttpRequest HttpRequests}. */ public void setAsyncRequestFactory(AsyncClientHttpRequestFactory asyncRequestFactory) { - Assert.notNull(asyncRequestFactory, "'asyncRequestFactory' must not be null"); + Assert.notNull(asyncRequestFactory, "AsyncClientHttpRequestFactory must not be null"); this.asyncRequestFactory = asyncRequestFactory; } @@ -64,15 +65,14 @@ public class AsyncHttpAccessor { } /** - * Create a new {@link AsyncClientHttpRequest} via this template's {@link - * AsyncClientHttpRequestFactory}. + * Create a new {@link AsyncClientHttpRequest} via this template's + * {@link AsyncClientHttpRequestFactory}. * @param url the URL to connect to * @param method the HTTP method to execute (GET, POST, etc.) * @return the created request * @throws IOException in case of I/O errors */ - protected AsyncClientHttpRequest createAsyncRequest(URI url, HttpMethod method) - throws IOException { + protected AsyncClientHttpRequest createAsyncRequest(URI url, HttpMethod method) throws IOException { AsyncClientHttpRequest request = getAsyncRequestFactory().createAsyncRequest(url, method); if (logger.isDebugEnabled()) { logger.debug("Created asynchronous " + method.name() + " request for \"" + url + "\""); diff --git a/spring-web/src/main/java/org/springframework/web/context/support/LiveBeansViewServlet.java b/spring-web/src/main/java/org/springframework/web/context/support/LiveBeansViewServlet.java index 702d87ee01e..abbf27cf561 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/LiveBeansViewServlet.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/LiveBeansViewServlet.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2017 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,6 +39,7 @@ public class LiveBeansViewServlet extends HttpServlet { private LiveBeansView liveBeansView; + @Override public void init() throws ServletException { this.liveBeansView = buildLiveBeansView(); @@ -49,7 +50,9 @@ public class LiveBeansViewServlet extends HttpServlet { } @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + String content = this.liveBeansView.getSnapshotAsJson(); response.setContentType("application/json"); response.setContentLength(content.length()); diff --git a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextAttributeExporter.java b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextAttributeExporter.java index 6c5427058f3..2fa3a84ddf6 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextAttributeExporter.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextAttributeExporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2017 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. @@ -65,16 +65,18 @@ public class ServletContextAttributeExporter implements ServletContextAware { @Override public void setServletContext(ServletContext servletContext) { - for (Map.Entry entry : attributes.entrySet()) { - String attributeName = entry.getKey(); - if (logger.isWarnEnabled()) { - if (servletContext.getAttribute(attributeName) != null) { - logger.warn("Replacing existing ServletContext attribute with name '" + attributeName + "'"); + if (this.attributes != null) { + for (Map.Entry entry : this.attributes.entrySet()) { + String attributeName = entry.getKey(); + if (logger.isWarnEnabled()) { + if (servletContext.getAttribute(attributeName) != null) { + logger.warn("Replacing existing ServletContext attribute with name '" + attributeName + "'"); + } + } + servletContext.setAttribute(attributeName, entry.getValue()); + if (logger.isInfoEnabled()) { + logger.info("Exported ServletContext attribute with name '" + attributeName + "'"); } - } - servletContext.setAttribute(attributeName, entry.getValue()); - if (logger.isInfoEnabled()) { - logger.info("Exported ServletContext attribute with name '" + attributeName + "'"); } } } diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java b/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java index 8cc07e465d0..e0d9e77f8a1 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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,19 +85,17 @@ public class SessionAttributesHandler { * session attributes through an {@link SessionAttributes} annotation. */ public boolean hasSessionAttributes() { - return (this.attributeNames.size() > 0 || this.attributeTypes.size() > 0); + return (!this.attributeNames.isEmpty() || !this.attributeTypes.isEmpty()); } /** * Whether the attribute name or type match the names and types specified * via {@code @SessionAttributes} in underlying controller. - * *

Attributes successfully resolved through this method are "remembered" * and subsequently used in {@link #retrieveAttributes(WebRequest)} and * {@link #cleanupAttributes(WebRequest)}. - * - * @param attributeName the attribute name to check, never {@code null} - * @param attributeType the type for the attribute, possibly {@code null} + * @param attributeName the attribute name to check + * @param attributeType the type for the attribute */ public boolean isHandlerSessionAttribute(String attributeName, Class attributeType) { Assert.notNull(attributeName, "Attribute name must not be null"); @@ -120,7 +118,6 @@ public class SessionAttributesHandler { for (String name : attributes.keySet()) { Object value = attributes.get(name); Class attrType = (value != null) ? value.getClass() : null; - if (isHandlerSessionAttribute(name, attrType)) { this.sessionAttributeStore.storeAttribute(request, name, value); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/RedirectViewControllerRegistration.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/RedirectViewControllerRegistration.java index 7a0fb28266b..df9b244f3aa 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/RedirectViewControllerRegistration.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/RedirectViewControllerRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 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 @@ public class RedirectViewControllerRegistration { /** * Set the specific redirect 3xx status code to use. - * *

If not set, {@link org.springframework.web.servlet.view.RedirectView} * will select {@code HttpStatus.MOVED_TEMPORARILY (302)} by default. */ public RedirectViewControllerRegistration setStatusCode(HttpStatus statusCode) { - Assert.isTrue(statusCode.is3xxRedirection(), "Not a redirect status code."); + Assert.isTrue(statusCode.is3xxRedirection(), "Not a redirect status code"); this.redirectView.setStatusCode(statusCode); return this; } @@ -63,7 +62,6 @@ public class RedirectViewControllerRegistration { * Whether to interpret a given redirect URL that starts with a slash ("/") * as relative to the current ServletContext, i.e. as relative to the web * application root. - * *

Default is {@code true}. */ public RedirectViewControllerRegistration setContextRelative(boolean contextRelative) { @@ -74,7 +72,6 @@ public class RedirectViewControllerRegistration { /** * Whether to propagate the query parameters of the current request through * to the target redirect URL. - * *

Default is {@code false}. */ public RedirectViewControllerRegistration setKeepQueryParams(boolean propagate) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java index a238d537ea7..0f0d9c51ec4 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 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,6 +19,7 @@ package org.springframework.web.servlet.handler; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.springframework.util.ObjectUtils; import org.springframework.util.PathMatcher; import org.springframework.web.context.request.WebRequestInterceptor; import org.springframework.web.servlet.HandlerInterceptor; @@ -99,15 +100,13 @@ public final class MappedInterceptor implements HandlerInterceptor { * method. This is an advanced property that is only required when using custom * PathMatcher implementations that support mapping metadata other than the * Ant-style path patterns supported by default. - * - * @param pathMatcher the path matcher to use */ public void setPathMatcher(PathMatcher pathMatcher) { this.pathMatcher = pathMatcher; } /** - * The configured PathMatcher, or {@code null}. + * The configured PathMatcher, or {@code null} if none. */ public PathMatcher getPathMatcher() { return this.pathMatcher; @@ -127,21 +126,6 @@ public final class MappedInterceptor implements HandlerInterceptor { return this.interceptor; } - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - return this.interceptor.preHandle(request, response, handler); - } - - @Override - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { - this.interceptor.postHandle(request, response, handler, modelAndView); - } - - @Override - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { - this.interceptor.afterCompletion(request, response, handler, ex); - } - /** * Returns {@code true} if the interceptor applies to the given request path. * @param lookupPath the current request path @@ -156,7 +140,7 @@ public final class MappedInterceptor implements HandlerInterceptor { } } } - if (this.includePatterns == null) { + if (ObjectUtils.isEmpty(this.includePatterns)) { return true; } else { @@ -168,4 +152,26 @@ public final class MappedInterceptor implements HandlerInterceptor { return false; } } + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + + return this.interceptor.preHandle(request, response, handler); + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, + ModelAndView modelAndView) throws Exception { + + this.interceptor.postHandle(request, response, handler, modelAndView); + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, + Exception ex) throws Exception { + + this.interceptor.afterCompletion(request, response, handler, ex); + } + } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketTransportRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketTransportRegistration.java index 0e9c2ec2f37..ce155a28c34 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketTransportRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketTransportRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.web.socket.config.annotation; +package org.springframework.web.socket.config.annotation; import java.util.ArrayList; import java.util.Arrays; @@ -44,16 +44,13 @@ public class WebSocketTransportRegistration { * Configure the maximum size for an incoming sub-protocol message. * For example a STOMP message may be received as multiple WebSocket messages * or multiple HTTP POST requests when SockJS fallback options are in use. - * *

In theory a WebSocket message can be almost unlimited in size. * In practice WebSocket servers impose limits on incoming message size. * STOMP clients for example tend to split large messages around 16K * boundaries. Therefore a server must be able to buffer partial content * and decode when enough data is received. Use this property to configure * the max size of the buffer to use. - * *

The default value is 64K (i.e. 64 * 1024). - * *

NOTE that the current version 1.2 of the STOMP spec * does not specifically discuss how to send STOMP messages over WebSocket. * Version 2 of the spec will but in the mean time existing client libraries @@ -75,7 +72,6 @@ public class WebSocketTransportRegistration { * Configure a time limit (in milliseconds) for the maximum amount of a time * allowed when sending messages to a WebSocket session or writing to an * HTTP response when SockJS fallback option are in use. - * *

In general WebSocket servers expect that messages to a single WebSocket * session are sent from a single thread at a time. This is automatically * guaranteed when using {@code @EnableWebSocketMessageBroker} configuration. @@ -83,14 +79,12 @@ public class WebSocketTransportRegistration { * subsequent messages are buffered until either the {@code sendTimeLimit} * or the {@code sendBufferSizeLimit} are reached at which point the session * state is cleared and an attempt is made to close the session. - * *

NOTE that the session time limit is checked only * on attempts to send additional messages. So if only a single message is * sent and it hangs, the session will not time out until another message is * sent or the underlying physical socket times out. So this is not a * replacement for WebSocket server or HTTP connection timeout but is rather * intended to control the extent of buffering of unsent messages. - * *

NOTE that closing the session may not succeed in * actually closing the physical socket and may also hang. This is true * especially when using blocking IO such as the BIO connector in Tomcat @@ -99,11 +93,9 @@ public class WebSocketTransportRegistration { * is used by default on Tomcat 8. If you must use blocking IO consider * customizing OS-level TCP settings, for example * {@code /proc/sys/net/ipv4/tcp_retries2} on Linux. - * *

The default value is 10 seconds (i.e. 10 * 10000). - * * @param timeLimit the timeout value in milliseconds; the value must be - * greater than 0, otherwise it is ignored. + * greater than 0, otherwise it is ignored. */ public WebSocketTransportRegistration setSendTimeLimit(int timeLimit) { this.sendTimeLimit = timeLimit; @@ -121,7 +113,6 @@ public class WebSocketTransportRegistration { * Configure the maximum amount of data to buffer when sending messages * to a WebSocket session, or an HTTP response when SockJS fallback * option are in use. - * *

In general WebSocket servers expect that messages to a single WebSocket * session are sent from a single thread at a time. This is automatically * guaranteed when using {@code @EnableWebSocketMessageBroker} configuration. @@ -129,7 +120,6 @@ public class WebSocketTransportRegistration { * subsequent messages are buffered until either the {@code sendTimeLimit} * or the {@code sendBufferSizeLimit} are reached at which point the session * state is cleared and an attempt is made to close the session. - * *

NOTE that closing the session may not succeed in * actually closing the physical socket and may also hang. This is true * especially when using blocking IO such as the BIO connector in Tomcat @@ -138,12 +128,10 @@ public class WebSocketTransportRegistration { * by default on Tomcat 8. If you must use blocking IO consider customizing * OS-level TCP settings, for example {@code /proc/sys/net/ipv4/tcp_retries2} * on Linux. - * *

The default value is 512K (i.e. 512 * 1024). - * * @param sendBufferSizeLimit the maximum number of bytes to buffer when - * sending messages; if the value is less than or equal to 0 then buffering - * is effectively disabled. + * sending messages; if the value is less than or equal to 0 then buffering + * is effectively disabled. */ public WebSocketTransportRegistration setSendBufferSizeLimit(int sendBufferSizeLimit) { this.sendBufferSizeLimit = sendBufferSizeLimit;