Browse Source

Polishing

pull/1215/head
Juergen Hoeller 8 years ago
parent
commit
3726c6f18d
  1. 4
      spring-aop/src/main/java/org/springframework/aop/config/AbstractInterceptorDrivenBeanDefinitionDecorator.java
  2. 4
      spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java
  3. 7
      spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java
  4. 3
      spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java
  5. 2
      spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java
  6. 4
      spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java
  7. 2
      spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java
  8. 2
      spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java
  9. 2
      spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java
  10. 4
      spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java
  11. 6
      spring-context/src/main/java/org/springframework/context/support/StaticMessageSource.java
  12. 5
      spring-context/src/main/java/org/springframework/scheduling/annotation/EnableAsync.java
  13. 2
      spring-core/src/main/java/org/springframework/core/Conventions.java
  14. 6
      spring-core/src/main/java/org/springframework/core/codec/ResourceRegionEncoder.java
  15. 6
      spring-expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java
  16. 2
      spring-expression/src/main/java/org/springframework/expression/spel/support/StandardTypeLocator.java
  17. 8
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java
  18. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java
  19. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReader.java
  20. 11
      spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethod.java
  21. 64
      spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandler.java
  22. 2
      spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java
  23. 2
      spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java
  24. 5
      spring-test/src/main/java/org/springframework/test/context/transaction/TestContextTransactionUtils.java
  25. 6
      spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/AbstractVersionStrategy.java
  26. 16
      spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java
  27. 2
      spring-web/src/main/java/org/springframework/http/codec/ResourceRegionHttpMessageWriter.java
  28. 4
      spring-web/src/main/java/org/springframework/http/converter/ResourceRegionHttpMessageConverter.java
  29. 4
      spring-web/src/main/java/org/springframework/remoting/caucho/HessianExporter.java
  30. 4
      spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.java
  31. 11
      spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java
  32. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java
  33. 8
      spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractVersionStrategy.java
  34. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/tags/UrlTag.java
  35. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractCachingViewResolver.java
  36. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java
  37. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolver.java

4
spring-aop/src/main/java/org/springframework/aop/config/AbstractInterceptorDrivenBeanDefinitionDecorator.java

@ -1,5 +1,5 @@ @@ -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.
@ -71,7 +71,7 @@ public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implement @@ -71,7 +71,7 @@ public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implement
BeanDefinition interceptorDefinition = createInterceptorDefinition(node);
// generate name and register the interceptor
String interceptorName = existingBeanName + "." + getInterceptorNameSuffix(interceptorDefinition);
String interceptorName = existingBeanName + '.' + getInterceptorNameSuffix(interceptorDefinition);
BeanDefinitionReaderUtils.registerBeanDefinition(
new BeanDefinitionHolder(interceptorDefinition, interceptorName), registry);

4
spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java

@ -1,5 +1,5 @@ @@ -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.
@ -246,7 +246,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { @@ -246,7 +246,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
*/
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String name = invocation.getMethod().getDeclaringClass().getName() + "." + invocation.getMethod().getName();
String name = ClassUtils.getQualifiedMethodName(invocation.getMethod());
StopWatch stopWatch = new StopWatch(name);
Object returnValue = null;
boolean exitThroughException = false;

7
spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java

@ -1,5 +1,5 @@ @@ -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.
@ -21,6 +21,7 @@ import java.lang.reflect.Method; @@ -21,6 +21,7 @@ import java.lang.reflect.Method;
import java.util.Arrays;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@ -129,8 +130,8 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo @@ -129,8 +130,8 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo
*/
@Override
public boolean matches(Method method, Class<?> targetClass) {
return ((targetClass != null && matchesPattern(targetClass.getName() + "." + method.getName())) ||
matchesPattern(method.getDeclaringClass().getName() + "." + method.getName()));
return ((targetClass != null && matchesPattern(ClassUtils.getQualifiedMethodName(method, targetClass))) ||
matchesPattern(ClassUtils.getQualifiedMethodName(method)));
}
/**

3
spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java

@ -40,6 +40,7 @@ import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcess @@ -40,6 +40,7 @@ import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcess
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
/**
@ -349,7 +350,7 @@ public class InitDestroyAnnotationBeanPostProcessor @@ -349,7 +350,7 @@ public class InitDestroyAnnotationBeanPostProcessor
}
this.method = method;
this.identifier = (Modifier.isPrivate(method.getModifiers()) ?
method.getDeclaringClass() + "." + method.getName() : method.getName());
ClassUtils.getQualifiedMethodName(method) : method.getName());
}
public Method getMethod() {

2
spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java

@ -280,7 +280,7 @@ public abstract class YamlProcessor { @@ -280,7 +280,7 @@ public abstract class YamlProcessor {
key = path + key;
}
else {
key = path + "." + key;
key = path + '.' + key;
}
}
Object value = entry.getValue();

4
spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java vendored

@ -1,5 +1,5 @@ @@ -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.
@ -98,7 +98,7 @@ public class EhCacheCache implements Cache { @@ -98,7 +98,7 @@ public class EhCacheCache implements Cache {
try {
value = valueLoader.call();
}
catch (Exception ex) {
catch (Throwable ex) {
throw new ValueRetrievalException(key, valueLoader, ex);
}
put(key, value);

2
spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java

@ -652,6 +652,8 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe @@ -652,6 +652,8 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
logger.info("Will start Quartz Scheduler [" + scheduler.getSchedulerName() +
"] in " + startupDelay + " seconds");
}
// Not using the Quartz startDelayed method since we explicitly want a daemon
// thread here, not keeping the JVM alive in case of all other threads ending.
Thread schedulerThread = new Thread() {
@Override
public void run() {

2
spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java vendored

@ -145,7 +145,7 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache { @@ -145,7 +145,7 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
try {
return toStoreValue(valueLoader.call());
}
catch (Exception ex) {
catch (Throwable ex) {
throw new ValueRetrievalException(key, valueLoader, ex);
}
}));

2
spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java

@ -335,7 +335,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC @@ -335,7 +335,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
Set<BeanDefinition> candidates = new LinkedHashSet<>();
try {
String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
resolveBasePackage(basePackage) + "/" + this.resourcePattern;
resolveBasePackage(basePackage) + '/' + this.resourcePattern;
Resource[] resources = this.resourcePatternResolver.getResources(packageSearchPath);
boolean traceEnabled = logger.isTraceEnabled();
boolean debugEnabled = logger.isDebugEnabled();

4
spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java

@ -142,7 +142,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor @@ -142,7 +142,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
group.add(entry.getKey(), bean);
}
}
if (phases.size() > 0) {
if (!phases.isEmpty()) {
List<Integer> keys = new ArrayList<>(phases.keySet());
Collections.sort(keys);
for (Integer key : keys) {
@ -195,7 +195,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor @@ -195,7 +195,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
}
group.add(entry.getKey(), bean);
}
if (phases.size() > 0) {
if (!phases.isEmpty()) {
List<Integer> keys = new ArrayList<>(phases.keySet());
Collections.sort(keys, Collections.reverseOrder());
for (Integer key : keys) {

6
spring-context/src/main/java/org/springframework/context/support/StaticMessageSource.java

@ -43,12 +43,12 @@ public class StaticMessageSource extends AbstractMessageSource { @@ -43,12 +43,12 @@ public class StaticMessageSource extends AbstractMessageSource {
@Override
protected String resolveCodeWithoutArguments(String code, Locale locale) {
return this.messages.get(code + "_" + locale.toString());
return this.messages.get(code + '_' + locale.toString());
}
@Override
protected MessageFormat resolveCode(String code, Locale locale) {
String key = code + "_" + locale.toString();
String key = code + '_' + locale.toString();
String msg = this.messages.get(key);
if (msg == null) {
return null;
@ -73,7 +73,7 @@ public class StaticMessageSource extends AbstractMessageSource { @@ -73,7 +73,7 @@ public class StaticMessageSource extends AbstractMessageSource {
Assert.notNull(code, "Code must not be null");
Assert.notNull(locale, "Locale must not be null");
Assert.notNull(msg, "Message must not be null");
this.messages.put(code + "_" + locale.toString(), msg);
this.messages.put(code + '_' + locale.toString(), msg);
if (logger.isDebugEnabled()) {
logger.debug("Added message [" + msg + "] for code [" + code + "] and Locale [" + locale + "]");
}

5
spring-context/src/main/java/org/springframework/scheduling/annotation/EnableAsync.java

@ -32,7 +32,9 @@ import org.springframework.core.Ordered; @@ -32,7 +32,9 @@ import org.springframework.core.Ordered;
* Enables Spring's asynchronous method execution capability, similar to functionality
* found in Spring's {@code <task:*>} XML namespace.
*
* <p>To be used together with @{@link Configuration Configuration} classes as follows:
* <p>To be used together with @{@link Configuration Configuration} classes as follows,
* enabling annotation-driven async processing for an entire Spring application context:
*
* <pre class="code">
* &#064;Configuration
* &#064;EnableAsync
@ -45,6 +47,7 @@ import org.springframework.core.Ordered; @@ -45,6 +47,7 @@ import org.springframework.core.Ordered;
* annotation, or any custom annotation specified via the {@link #annotation} attribute.
* The aspect is added transparently for any registered bean, for instance via this
* configuration:
*
* <pre class="code">
* &#064;Configuration
* public class AnotherAppConfig {

2
spring-core/src/main/java/org/springframework/core/Conventions.java

@ -241,7 +241,7 @@ public abstract class Conventions { @@ -241,7 +241,7 @@ public abstract class Conventions {
public static String getQualifiedAttributeName(Class<?> enclosingClass, String attributeName) {
Assert.notNull(enclosingClass, "'enclosingClass' must not be null");
Assert.notNull(attributeName, "'attributeName' must not be null");
return enclosingClass.getName() + "." + attributeName;
return enclosingClass.getName() + '.' + attributeName;
}

6
spring-core/src/main/java/org/springframework/core/codec/ResourceRegionEncoder.java

@ -37,7 +37,6 @@ import org.springframework.core.io.support.ResourceRegion; @@ -37,7 +37,6 @@ import org.springframework.core.io.support.ResourceRegion;
import org.springframework.util.Assert;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
import org.springframework.util.ResourceUtils;
import org.springframework.util.StreamUtils;
/**
@ -73,6 +72,7 @@ public class ResourceRegionEncoder extends AbstractEncoder<ResourceRegion> { @@ -73,6 +72,7 @@ public class ResourceRegionEncoder extends AbstractEncoder<ResourceRegion> {
}
@Override
@SuppressWarnings("unchecked")
public Flux<DataBuffer> encode(Publisher<? extends ResourceRegion> inputStream,
DataBufferFactory bufferFactory, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
@ -138,10 +138,10 @@ public class ResourceRegionEncoder extends AbstractEncoder<ResourceRegion> { @@ -138,10 +138,10 @@ public class ResourceRegionEncoder extends AbstractEncoder<ResourceRegion> {
long end = start + region.getCount() - 1;
OptionalLong contentLength = contentLength(region.getResource());
if (contentLength.isPresent()) {
return getAsciiBytes("Content-Range: bytes " + start + "-" + end + "/" + contentLength.getAsLong() + "\r\n\r\n");
return getAsciiBytes("Content-Range: bytes " + start + '-' + end + '/' + contentLength.getAsLong() + "\r\n\r\n");
}
else {
return getAsciiBytes("Content-Range: bytes " + start + "-" + end + "\r\n\r\n");
return getAsciiBytes("Content-Range: bytes " + start + '-' + end + "\r\n\r\n");
}
}

6
spring-expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java

@ -1,5 +1,5 @@ @@ -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.
@ -30,6 +30,7 @@ import org.springframework.expression.spel.ExpressionState; @@ -30,6 +30,7 @@ import org.springframework.expression.spel.ExpressionState;
import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessage;
import org.springframework.expression.spel.support.ReflectionHelper;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
/**
@ -103,8 +104,7 @@ public class FunctionReference extends SpelNodeImpl { @@ -103,8 +104,7 @@ public class FunctionReference extends SpelNodeImpl {
// Only static methods can be called in this way
if (!Modifier.isStatic(method.getModifiers())) {
throw new SpelEvaluationException(getStartPosition(),
SpelMessage.FUNCTION_MUST_BE_STATIC,
method.getDeclaringClass().getName() + "." + method.getName(), this.name);
SpelMessage.FUNCTION_MUST_BE_STATIC, ClassUtils.getQualifiedMethodName(method), this.name);
}
argumentConversionOccurred = false;

2
spring-expression/src/main/java/org/springframework/expression/spel/support/StandardTypeLocator.java

@ -105,7 +105,7 @@ public class StandardTypeLocator implements TypeLocator { @@ -105,7 +105,7 @@ public class StandardTypeLocator implements TypeLocator {
}
for (String prefix : this.knownPackagePrefixes) {
try {
nameToLookup = prefix + "." + typeName;
nameToLookup = prefix + '.' + typeName;
return ClassUtils.forName(nameToLookup, this.classLoader);
}
catch (ClassNotFoundException ex) {

8
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java

@ -316,8 +316,8 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { @@ -316,8 +316,8 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
String metaDataSchemaName = metaDataSchemaNameToUse(schemaName);
String metaDataProcedureName = procedureNameToUse(procedureName);
if (logger.isDebugEnabled()) {
logger.debug("Retrieving metadata for " + metaDataCatalogName + "/" +
metaDataSchemaName + "/" + metaDataProcedureName);
logger.debug("Retrieving metadata for " + metaDataCatalogName + '/' +
metaDataSchemaName + '/' + metaDataProcedureName);
}
ResultSet procs = null;
@ -325,8 +325,8 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { @@ -325,8 +325,8 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
procs = databaseMetaData.getProcedures(metaDataCatalogName, metaDataSchemaName, metaDataProcedureName);
List<String> found = new ArrayList<>();
while (procs.next()) {
found.add(procs.getString("PROCEDURE_CAT") + "." + procs.getString("PROCEDURE_SCHEM") +
"." + procs.getString("PROCEDURE_NAME"));
found.add(procs.getString("PROCEDURE_CAT") + '.' + procs.getString("PROCEDURE_SCHEM") +
'.' + procs.getString("PROCEDURE_NAME"));
}
procs.close();

4
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java

@ -371,8 +371,8 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { @@ -371,8 +371,8 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
String metaDataSchemaName = metaDataSchemaNameToUse(tmd.getSchemaName());
String metaDataTableName = tableNameToUse(tmd.getTableName());
if (logger.isDebugEnabled()) {
logger.debug("Retrieving metadata for " + metaDataCatalogName + "/" +
metaDataSchemaName + "/" + metaDataTableName);
logger.debug("Retrieving metadata for " + metaDataCatalogName + '/' +
metaDataSchemaName + '/' + metaDataTableName);
}
try {
tableColumns = databaseMetaData.getColumns(

4
spring-jdbc/src/main/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReader.java

@ -1,5 +1,5 @@ @@ -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.
@ -112,7 +112,7 @@ public class JdbcBeanDefinitionReader { @@ -112,7 +112,7 @@ public class JdbcBeanDefinitionReader {
String property = rs.getString(2);
String value = rs.getString(3);
// Make a properties entry by combining bean name and property.
props.setProperty(beanName + "." + property, value);
props.setProperty(beanName + '.' + property, value);
}
});
this.propReader.registerBeanDefinitions(props);

11
spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethod.java

@ -28,6 +28,7 @@ import org.springframework.core.ParameterNameDiscoverer; @@ -28,6 +28,7 @@ import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.core.ResolvableType;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.HandlerMethod;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
/**
@ -106,15 +107,13 @@ public class InvocableHandlerMethod extends HandlerMethod { @@ -106,15 +107,13 @@ public class InvocableHandlerMethod extends HandlerMethod {
public Object invoke(Message<?> message, Object... providedArgs) throws Exception {
Object[] args = getMethodArgumentValues(message, providedArgs);
if (logger.isTraceEnabled()) {
StringBuilder sb = new StringBuilder("Invoking [");
sb.append(getBeanType().getSimpleName()).append(".");
sb.append(getMethod().getName()).append("] method with arguments ");
sb.append(Arrays.asList(args));
logger.trace(sb.toString());
logger.trace("Invoking '" + ClassUtils.getQualifiedMethodName(getMethod(), getBeanType()) +
"' with arguments " + Arrays.toString(args));
}
Object returnValue = doInvoke(args);
if (logger.isTraceEnabled()) {
logger.trace("Method [" + getMethod().getName() + "] returned [" + returnValue + "]");
logger.trace("Method [" + ClassUtils.getQualifiedMethodName(getMethod(), getBeanType()) +
"] returned [" + returnValue + "]");
}
return returnValue;
}

64
spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandler.java

@ -133,13 +133,11 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH @@ -133,13 +133,11 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
@Override
public boolean supportsReturnType(MethodParameter returnType) {
if (returnType.hasMethodAnnotation(SendTo.class) ||
return (returnType.hasMethodAnnotation(SendTo.class) ||
AnnotatedElementUtils.hasAnnotation(returnType.getDeclaringClass(), SendTo.class) ||
returnType.hasMethodAnnotation(SendToUser.class) ||
AnnotatedElementUtils.hasAnnotation(returnType.getDeclaringClass(), SendToUser.class)) {
return true;
}
return !this.annotationRequired;
AnnotatedElementUtils.hasAnnotation(returnType.getDeclaringClass(), SendToUser.class) ||
!this.annotationRequired);
}
@Override
@ -188,56 +186,34 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH @@ -188,56 +186,34 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
}
private Object findAnnotation(MethodParameter returnType) {
Annotation[] annot = new Annotation[4];
annot[0] = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendToUser.class);
annot[1] = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendTo.class);
annot[2] = AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendToUser.class);
annot[3] = AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendTo.class);
if (annot[0] != null && !ObjectUtils.isEmpty(((SendToUser) annot[0]).value())) {
return annot[0];
Annotation[] anns = new Annotation[4];
anns[0] = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendToUser.class);
anns[1] = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendTo.class);
anns[2] = AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendToUser.class);
anns[3] = AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendTo.class);
if (anns[0] != null && !ObjectUtils.isEmpty(((SendToUser) anns[0]).value())) {
return anns[0];
}
if (annot[1] != null && !ObjectUtils.isEmpty(((SendTo) annot[1]).value())) {
return annot[1];
if (anns[1] != null && !ObjectUtils.isEmpty(((SendTo) anns[1]).value())) {
return anns[1];
}
if (annot[2] != null && !ObjectUtils.isEmpty(((SendToUser) annot[2]).value())) {
return annot[2];
if (anns[2] != null && !ObjectUtils.isEmpty(((SendToUser) anns[2]).value())) {
return anns[2];
}
if (annot[3] != null && !ObjectUtils.isEmpty(((SendTo) annot[3]).value())) {
return annot[3];
if (anns[3] != null && !ObjectUtils.isEmpty(((SendTo) anns[3]).value())) {
return anns[3];
}
for (int i=0; i < 4; i++) {
if (annot[i] != null) {
return annot[i];
if (anns[i] != null) {
return anns[i];
}
}
return null;
}
private SendToUser getSendToUser(MethodParameter returnType) {
SendToUser annot = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendToUser.class);
if (annot != null && !ObjectUtils.isEmpty(annot.value())) {
return annot;
}
SendToUser typeAnnot = AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendToUser.class);
if (typeAnnot != null && !ObjectUtils.isEmpty(typeAnnot.value())) {
return typeAnnot;
}
return (annot != null ? annot : typeAnnot);
}
private SendTo getSendTo(MethodParameter returnType) {
SendTo sendTo = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendTo.class);
if (sendTo != null && !ObjectUtils.isEmpty(sendTo.value())) {
return sendTo;
}
else {
return AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendTo.class);
}
}
@SuppressWarnings("unchecked")
private PlaceholderResolver initVarResolver(MessageHeaders headers) {
String name = DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER;
@ -268,7 +244,7 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH @@ -268,7 +244,7 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
}
return (destination.startsWith("/") ?
new String[] {defaultPrefix + destination} : new String[] {defaultPrefix + "/" + destination});
new String[] {defaultPrefix + destination} : new String[] {defaultPrefix + '/' + destination});
}
private MessageHeaders createHeaders(String sessionId, MethodParameter returnType) {

2
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java

@ -211,7 +211,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor { @@ -211,7 +211,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
}
trySetStompHeaderForSubscriptionId();
if (getMessageId() == null) {
String messageId = getSessionId() + "-" + messageIdCounter.getAndIncrement();
String messageId = getSessionId() + '-' + messageIdCounter.getAndIncrement();
setNativeHeader(STOMP_MESSAGE_ID_HEADER, messageId);
}
}

2
spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java

@ -77,7 +77,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati @@ -77,7 +77,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
catch (UnknownHostException ex) {
host = "unknown";
}
return host + "-" + UUID.randomUUID();
return host + '-' + UUID.randomUUID();
}

5
spring-test/src/main/java/org/springframework/test/context/transaction/TestContextTransactionUtils.java

@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
package org.springframework.test.context.transaction;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
@ -33,6 +32,7 @@ import org.springframework.transaction.annotation.TransactionManagementConfigure @@ -33,6 +32,7 @@ import org.springframework.transaction.annotation.TransactionManagementConfigure
import org.springframework.transaction.interceptor.DelegatingTransactionAttribute;
import org.springframework.transaction.interceptor.TransactionAttribute;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
@ -241,10 +241,9 @@ public abstract class TestContextTransactionUtils { @@ -241,10 +241,9 @@ public abstract class TestContextTransactionUtils {
private final String name;
public TestContextTransactionAttribute(TransactionAttribute targetAttribute, TestContext testContext) {
super(targetAttribute);
this.name = testContext.getTestClass().getName() + "." + testContext.getTestMethod().getName();
this.name = ClassUtils.getQualifiedMethodName(testContext.getTestMethod(), testContext.getTestClass());
}
@Override

6
spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/AbstractVersionStrategy.java

@ -105,7 +105,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy { @@ -105,7 +105,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
}
else {
return (this.prefix.endsWith("/") || path.startsWith("/") ?
this.prefix + path : this.prefix + "/" + path);
this.prefix + path : this.prefix + '/' + path);
}
}
}
@ -124,7 +124,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy { @@ -124,7 +124,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
Matcher matcher = pattern.matcher(requestPath);
if (matcher.find()) {
String match = matcher.group(1);
return (match.contains("-") ? match.substring(match.lastIndexOf("-") + 1) : match);
return (match.contains("-") ? match.substring(match.lastIndexOf('-') + 1) : match);
}
else {
return null;
@ -140,7 +140,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy { @@ -140,7 +140,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
public String addVersion(String requestPath, String version) {
String baseFilename = StringUtils.stripFilenameExtension(requestPath);
String extension = StringUtils.getFilenameExtension(requestPath);
return (baseFilename + "-" + version + "." + extension);
return (baseFilename + '-' + version + '.' + extension);
}
}

16
spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java

@ -32,13 +32,13 @@ import org.springframework.core.GenericTypeResolver; @@ -32,13 +32,13 @@ import org.springframework.core.GenericTypeResolver;
import org.springframework.core.MethodParameter;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.ui.ModelMap;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.reactive.HandlerResult;
import org.springframework.web.server.ServerWebExchange;
/**
* Extension of HandlerMethod that can invoke the target method after resolving
* its method arguments.
@ -160,22 +160,22 @@ public class InvocableHandlerMethod extends HandlerMethod { @@ -160,22 +160,22 @@ public class InvocableHandlerMethod extends HandlerMethod {
private String getDetailedErrorMessage(String message, MethodParameter param) {
StringBuilder sb = new StringBuilder(message);
sb.append("argument [" + param.getParameterIndex() + "] ");
sb.append("of type [" + param.getParameterType().getName() + "] ");
sb.append("on method [" + getBridgedMethod().toGenericString() + "]");
sb.append("argument [").append(param.getParameterIndex()).append("] ");
sb.append("of type [").append(param.getParameterType().getName()).append("] ");
sb.append("on method [").append(getBridgedMethod().toGenericString()).append("]");
return sb.toString();
}
private Object doInvoke(Object[] args) throws Exception {
if (logger.isTraceEnabled()) {
String target = getBeanType().getSimpleName() + "." + getMethod().getName();
logger.trace("Invoking [" + target + "] method with arguments " + Arrays.toString(args));
logger.trace("Invoking '" + ClassUtils.getQualifiedMethodName(getMethod(), getBeanType()) +
"' with arguments " + Arrays.toString(args));
}
ReflectionUtils.makeAccessible(getBridgedMethod());
Object returnValue = getBridgedMethod().invoke(getBean(), args);
if (logger.isTraceEnabled()) {
String target = getBeanType().getSimpleName() + "." + getMethod().getName();
logger.trace("Method [" + target + "] returned [" + returnValue + "]");
logger.trace("Method [" + ClassUtils.getQualifiedMethodName(getMethod(), getBeanType()) +
"] returned [" + returnValue + "]");
}
return returnValue;
}

2
spring-web/src/main/java/org/springframework/http/codec/ResourceRegionHttpMessageWriter.java

@ -86,7 +86,7 @@ class ResourceRegionHttpMessageWriter extends EncoderHttpMessageWriter<ResourceR @@ -86,7 +86,7 @@ class ResourceRegionHttpMessageWriter extends EncoderHttpMessageWriter<ResourceR
long start = region.getPosition();
long end = start + region.getCount() - 1;
end = Math.min(end, length - 1);
outputMessage.getHeaders().add("Content-Range", "bytes " + start + "-" + end + "/" + length);
outputMessage.getHeaders().add("Content-Range", "bytes " + start + '-' + end + '/' + length);
outputMessage.getHeaders().setContentLength(end - start + 1);
});
outputMessage.getHeaders().setContentType(contentType);

4
spring-web/src/main/java/org/springframework/http/converter/ResourceRegionHttpMessageConverter.java

@ -128,7 +128,7 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa @@ -128,7 +128,7 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
Long resourceLength = region.getResource().contentLength();
end = Math.min(end, resourceLength - 1);
long rangeLength = end - start + 1;
responseHeaders.add("Content-Range", "bytes " + start + "-" + end + "/" + resourceLength);
responseHeaders.add("Content-Range", "bytes " + start + '-' + end + '/' + resourceLength);
responseHeaders.setContentLength(rangeLength);
InputStream in = region.getResource().getInputStream();
try {
@ -167,7 +167,7 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa @@ -167,7 +167,7 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
}
Long resourceLength = region.getResource().contentLength();
end = Math.min(end, resourceLength - 1);
print(out, "Content-Range: bytes " + start + "-" + end + "/" + resourceLength);
print(out, "Content-Range: bytes " + start + '-' + end + '/' + resourceLength);
println(out);
println(out);
// Printing content

4
spring-web/src/main/java/org/springframework/remoting/caucho/HessianExporter.java

@ -1,5 +1,5 @@ @@ -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.
@ -182,7 +182,7 @@ public class HessianExporter extends RemoteExporter implements InitializingBean @@ -182,7 +182,7 @@ public class HessianExporter extends RemoteExporter implements InitializingBean
major = isToUse.read();
minor = isToUse.read();
if (major != 0x02) {
throw new IOException("Version " + major + "." + minor + " is not understood");
throw new IOException("Version " + major + '.' + minor + " is not understood");
}
in = new Hessian2Input(isToUse);
out = new Hessian2Output(osToUse);

4
spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.java

@ -144,6 +144,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter @@ -144,6 +144,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
* Set whether the request payload (body) should be included in the log message.
* <p>Should be configured using an {@code <init-param>} for parameter name
* "includePayload" in the filter definition in {@code web.xml}.
* @since 3.0
*/
public void setIncludePayload(boolean includePayload) {
this.includePayload = includePayload;
@ -151,6 +152,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter @@ -151,6 +152,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
/**
* Return whether the request payload (body) should be included in the log message.
* @since 3.0
*/
protected boolean isIncludePayload() {
return this.includePayload;
@ -159,6 +161,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter @@ -159,6 +161,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
/**
* Sets the maximum length of the payload body to be included in the log message.
* Default is 50 characters.
* @since 3.0
*/
public void setMaxPayloadLength(int maxPayloadLength) {
Assert.isTrue(maxPayloadLength >= 0, "'maxPayloadLength' should be larger than or equal to 0");
@ -167,6 +170,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter @@ -167,6 +170,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
/**
* Return the maximum length of the payload body to be included in the log message.
* @since 3.0
*/
protected int getMaxPayloadLength() {
return this.maxPayloadLength;

11
spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java

@ -24,6 +24,7 @@ import org.springframework.core.DefaultParameterNameDiscoverer; @@ -24,6 +24,7 @@ import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.core.GenericTypeResolver;
import org.springframework.core.MethodParameter;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.support.SessionStatus;
@ -127,15 +128,13 @@ public class InvocableHandlerMethod extends HandlerMethod { @@ -127,15 +128,13 @@ public class InvocableHandlerMethod extends HandlerMethod {
Object[] args = getMethodArgumentValues(request, mavContainer, providedArgs);
if (logger.isTraceEnabled()) {
StringBuilder sb = new StringBuilder("Invoking [");
sb.append(getBeanType().getSimpleName()).append(".");
sb.append(getMethod().getName()).append("] method with arguments ");
sb.append(Arrays.asList(args));
logger.trace(sb.toString());
logger.trace("Invoking '" + ClassUtils.getQualifiedMethodName(getMethod(), getBeanType()) +
"' with arguments " + Arrays.toString(args));
}
Object returnValue = doInvoke(args);
if (logger.isTraceEnabled()) {
logger.trace("Method [" + getMethod().getName() + "] returned [" + returnValue + "]");
logger.trace("Method [" + ClassUtils.getQualifiedMethodName(getMethod(), getBeanType()) +
"] returned [" + returnValue + "]");
}
return returnValue;
}

2
spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java

@ -641,7 +641,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic @@ -641,7 +641,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
else {
// Generate default id...
wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX +
ObjectUtils.getDisplayString(getServletContext().getContextPath()) + "/" + getServletName());
ObjectUtils.getDisplayString(getServletContext().getContextPath()) + '/' + getServletName());
}
}

8
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractVersionStrategy.java

@ -1,5 +1,5 @@ @@ -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.
@ -105,7 +105,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy { @@ -105,7 +105,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
}
else {
return (this.prefix.endsWith("/") || path.startsWith("/") ?
this.prefix + path : this.prefix + "/" + path);
this.prefix + path : this.prefix + '/' + path);
}
}
}
@ -124,7 +124,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy { @@ -124,7 +124,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
Matcher matcher = pattern.matcher(requestPath);
if (matcher.find()) {
String match = matcher.group(1);
return (match.contains("-") ? match.substring(match.lastIndexOf("-") + 1) : match);
return (match.contains("-") ? match.substring(match.lastIndexOf('-') + 1) : match);
}
else {
return null;
@ -140,7 +140,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy { @@ -140,7 +140,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
public String addVersion(String requestPath, String version) {
String baseFilename = StringUtils.stripFilenameExtension(requestPath);
String extension = StringUtils.getFilenameExtension(requestPath);
return (baseFilename + "-" + version + "." + extension);
return (baseFilename + '-' + version + '.' + extension);
}
}

2
spring-webmvc/src/main/java/org/springframework/web/servlet/tags/UrlTag.java

@ -300,7 +300,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware { @@ -300,7 +300,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
}
}
else {
template = URL_TEMPLATE_DELIMITER_PREFIX + "/" + param.getName() + URL_TEMPLATE_DELIMITER_SUFFIX;
template = URL_TEMPLATE_DELIMITER_PREFIX + '/' + param.getName() + URL_TEMPLATE_DELIMITER_SUFFIX;
if (uri.contains(template)) {
usedParams.add(param.getName());
try {

2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractCachingViewResolver.java

@ -179,7 +179,7 @@ public abstract class AbstractCachingViewResolver extends WebApplicationObjectSu @@ -179,7 +179,7 @@ public abstract class AbstractCachingViewResolver extends WebApplicationObjectSu
* lead to a different view resource.
*/
protected Object getCacheKey(String viewName, Locale locale) {
return viewName + "_" + locale;
return viewName + '_' + locale;
}
/**

2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java

@ -303,7 +303,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport @@ -303,7 +303,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
for (MediaType requestedMediaType : requestedMediaTypes) {
List<String> extensions = this.contentNegotiationManager.resolveFileExtensions(requestedMediaType);
for (String extension : extensions) {
String viewNameWithExtension = viewName + "." + extension;
String viewNameWithExtension = viewName + '.' + extension;
view = viewResolver.resolveViewName(viewNameWithExtension, locale);
if (view != null) {
candidateViews.add(view);

2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolver.java

@ -70,7 +70,7 @@ public class GroovyMarkupViewResolver extends AbstractTemplateViewResolver { @@ -70,7 +70,7 @@ public class GroovyMarkupViewResolver extends AbstractTemplateViewResolver {
*/
@Override
protected Object getCacheKey(String viewName, Locale locale) {
return viewName + "_" + locale;
return viewName + '_' + locale;
}
}

Loading…
Cancel
Save