From eeebd51f57f452c57bc159fa8a2ad9746c4c2f8c Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 20 Jun 2018 19:44:39 -0700 Subject: [PATCH] Use consistent class design Update all classes so that inner classes are always last. Also ensure that utility classes are always final and have a private constructor and make exceptions final whenever possible. Issue: SPR-16968 --- .../springframework/aop/TrueClassFilter.java | 4 +- .../aop/TrueMethodMatcher.java | 4 +- .../org/springframework/aop/TruePointcut.java | 4 +- .../aspectj/AspectJExpressionPointcut.java | 27 +-- ...ntiationModelAwarePointcutAdvisorImpl.java | 6 +- .../annotation/NotAnAtAspectException.java | 4 +- .../autoproxy/ProxyCreationContext.java | 6 +- .../ExposeInvocationInterceptor.java | 2 +- .../aop/target/EmptyTargetSource.java | 2 +- .../cache/aspectj/AnyThrow.java | 8 +- .../beans/BeanInstantiationException.java | 12 +- .../beans/CachedIntrospectionResults.java | 2 +- .../beans/InvalidPropertyException.java | 6 +- .../beans/NotWritablePropertyException.java | 7 +- .../beans/PropertyAccessException.java | 5 +- .../beans/PropertyBatchUpdateException.java | 2 +- .../beans/PropertyDescriptorUtils.java | 9 +- .../beans/PropertyEditorRegistrySupport.java | 2 +- .../beans/factory/BeanCreationException.java | 10 +- .../factory/BeanDefinitionStoreException.java | 12 +- .../BeanNotOfRequiredTypeException.java | 6 +- .../factory/CannotLoadBeanClassException.java | 8 +- .../NoSuchBeanDefinitionException.java | 10 +- .../NoUniqueBeanDefinitionException.java | 10 +- .../UnsatisfiedDependencyException.java | 5 +- .../config/PropertyPlaceholderConfigurer.java | 4 +- .../support/BeanDefinitionBuilder.java | 4 +- .../support/BeanDefinitionReaderUtils.java | 8 +- .../mail/MailSendException.java | 3 +- .../config/CacheManagementConfigUtils.java | 6 +- .../annotation/AnnotationConfigUtils.java | 6 +- .../annotation/BeanAnnotationHelper.java | 9 +- .../annotation/ScopedProxyCreator.java | 9 +- .../index/CandidateComponentsIndexLoader.java | 8 +- .../PostProcessorRegistrationDelegate.java | 7 +- .../datetime/joda/JodaTimeContextHolder.java | 6 +- .../datetime/joda/JodaTimeConverters.java | 7 +- .../standard/DateTimeContextHolder.java | 6 +- .../datetime/standard/DateTimeConverters.java | 7 +- .../jmx/support/ObjectNameManager.java | 9 +- .../config/TaskManagementConfigUtils.java | 9 +- .../scripting/ScriptCompilationException.java | 6 +- .../scripting/bsh/BshScriptUtils.java | 4 +- .../core/ReactiveTypeDescriptor.java | 2 +- .../springframework/core/SpringVersion.java | 9 +- .../core/annotation/AnnotationUtils.java | 2 +- .../core/codec/CharSequenceEncoder.java | 2 +- .../core/codec/StringDecoder.java | 2 +- .../core/env/ProfilesParser.java | 5 +- .../springframework/util/ReflectionUtils.java | 42 ++-- .../expression/ExpressionException.java | 8 +- .../expression/spel/CodeFlow.java | 29 +-- .../expression/spel/ast/Operator.java | 28 +-- .../spel/standard/SpelCompiler.java | 4 +- .../spel/support/BooleanTypedValue.java | 2 +- .../support/DataBindingMethodResolver.java | 2 +- .../support/DataBindingPropertyAccessor.java | 2 +- .../spel/support/SimpleEvaluationContext.java | 2 +- .../InstrumentationSavingAgent.java | 8 +- .../jdbc/BadSqlGrammarException.java | 4 +- ...ncorrectResultSetColumnCountException.java | 6 +- .../jdbc/InvalidResultSetAccessException.java | 5 +- ...ffectedIncorrectNumberOfRowsException.java | 4 +- .../config/DatabasePopulatorConfigUtils.java | 7 +- .../metadata/CallMetaDataProviderFactory.java | 6 +- .../TableMetaDataProviderFactory.java | 6 +- .../UserCredentialsDataSourceAdapter.java | 4 +- .../EmbeddedDatabaseConfigurerFactory.java | 5 + .../embedded/OutputStreamFactory.java | 9 +- .../CustomSQLExceptionTranslatorRegistry.java | 4 +- ...erCredentialsConnectionFactoryAdapter.java | 6 +- ...inationVariableMethodArgumentResolver.java | 2 +- .../support/HeaderMethodArgumentResolver.java | 4 +- .../MethodArgumentNotValidException.java | 5 +- .../stomp/StompBrokerRelayMessageHandler.java | 2 +- ...jectOptimisticLockingFailureException.java | 8 +- .../orm/ObjectRetrievalFailureException.java | 8 +- .../HibernateTransactionManager.java | 2 +- .../orm/jpa/ExtendedEntityManagerCreator.java | 2 +- .../orm/jpa/JpaTransactionManager.java | 2 +- .../oxm/jaxb/Jaxb2Marshaller.java | 7 +- .../oxm/support/MarshallingSource.java | 4 +- .../reactive/MockServerHttpRequest.java | 2 +- .../mock/jndi/SimpleNamingContext.java | 4 +- .../mock/web/MockFilterChain.java | 2 +- .../function/server/MockServerRequest.java | 2 +- .../annotation/SystemProfileValueSource.java | 4 +- .../test/annotation/TestAnnotationUtils.java | 9 +- .../context/transaction/TestTransaction.java | 7 +- .../transaction/TransactionContextHolder.java | 6 +- .../test/jdbc/JdbcTestUtils.java | 8 +- .../test/web/client/ExpectedCount.java | 4 +- .../web/client/MockRestServiceServer.java | 2 +- .../web/servlet/setup/MockMvcBuilders.java | 7 +- ...ncorrectResultSizeDataAccessException.java | 6 +- .../connection/SingleConnectionFactory.java | 2 +- .../HeuristicCompletionException.java | 2 +- .../transaction/InvalidTimeoutException.java | 4 +- .../AbstractPlatformTransactionManager.java | 2 +- .../http/ContentDisposition.java | 2 +- .../http/InvalidMediaTypeException.java | 4 +- .../http/MediaTypeFactory.java | 6 +- .../http/codec/CodecConfigurerFactory.java | 8 +- .../http/codec/ServerSentEvent.java | 2 +- .../http/codec/json/Jackson2Tokenizer.java | 2 +- .../http/server/DefaultPathContainer.java | 2 +- ...ttpRequestMethodNotSupportedException.java | 6 +- .../web/HttpSessionRequiredException.java | 5 +- .../RelativeRedirectResponseWrapper.java | 4 +- .../web/method/HandlerTypePredicate.java | 2 +- ...ractCookieValueMethodArgumentResolver.java | 2 +- ...ExpressionValueMethodArgumentResolver.java | 2 +- .../RequestHeaderMethodArgumentResolver.java | 2 +- .../server/adapter/WebHttpHandlerBuilder.java | 2 +- .../web/util/HierarchicalUriComponents.java | 81 ++++--- .../web/util/JavaScriptUtils.java | 9 +- .../springframework/web/util/UriTemplate.java | 4 +- .../web/util/pattern/PathPattern.java | 229 +++++++++--------- .../CookieValueMethodArgumentResolver.java | 2 +- ...ExpressionValueMethodArgumentResolver.java | 2 +- .../MatrixVariableMethodArgumentResolver.java | 2 +- .../RequestHeaderMethodArgumentResolver.java | 2 +- .../ModelAndViewDefiningException.java | 2 +- .../MatrixVariableMethodArgumentResolver.java | 4 +- .../MessageBrokerBeanDefinitionParser.java | 2 +- .../config/WebSocketNamespaceUtils.java | 9 +- ...bSocketAnnotationMethodMessageHandler.java | 4 +- .../sockjs/support/AbstractSockJsService.java | 9 +- 128 files changed, 619 insertions(+), 418 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/TrueClassFilter.java b/spring-aop/src/main/java/org/springframework/aop/TrueClassFilter.java index 4777e757ba5..8009b3ccad5 100644 --- a/spring-aop/src/main/java/org/springframework/aop/TrueClassFilter.java +++ b/spring-aop/src/main/java/org/springframework/aop/TrueClassFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import java.io.Serializable; * @author Rod Johnson */ @SuppressWarnings("serial") -class TrueClassFilter implements ClassFilter, Serializable { +final class TrueClassFilter implements ClassFilter, Serializable { public static final TrueClassFilter INSTANCE = new TrueClassFilter(); diff --git a/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java index 7442d72ec4a..91640b6d6db 100644 --- a/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java +++ b/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.springframework.lang.Nullable; * @author Rod Johnson */ @SuppressWarnings("serial") -class TrueMethodMatcher implements MethodMatcher, Serializable { +final class TrueMethodMatcher implements MethodMatcher, Serializable { public static final TrueMethodMatcher INSTANCE = new TrueMethodMatcher(); diff --git a/spring-aop/src/main/java/org/springframework/aop/TruePointcut.java b/spring-aop/src/main/java/org/springframework/aop/TruePointcut.java index 1a44c2ac268..a6c8c9b92d7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/TruePointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/TruePointcut.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import java.io.Serializable; * @author Rod Johnson */ @SuppressWarnings("serial") -class TruePointcut implements Pointcut, Serializable { +final class TruePointcut implements Pointcut, Serializable { public static final TruePointcut INSTANCE = new TruePointcut(); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java index 5f3a68e4ca6..68c1e02dd6d 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java @@ -561,6 +561,19 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut return sb.toString(); } + //--------------------------------------------------------------------- + // Serialization support + //--------------------------------------------------------------------- + + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Rely on default serialization, just initialize state after deserialization. + ois.defaultReadObject(); + + // Initialize transient fields. + // pointcutExpression will be initialized lazily by checkReadyToMatch() + this.shadowMatchCache = new ConcurrentHashMap<>(32); + } + /** * Handler for the Spring-specific {@code bean()} pointcut designator @@ -657,20 +670,6 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut } - //--------------------------------------------------------------------- - // Serialization support - //--------------------------------------------------------------------- - - private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { - // Rely on default serialization, just initialize state after deserialization. - ois.defaultReadObject(); - - // Initialize transient fields. - // pointcutExpression will be initialized lazily by checkReadyToMatch() - this.shadowMatchCache = new ConcurrentHashMap<>(32); - } - - private static class DefensiveShadowMatch implements ShadowMatch { private final ShadowMatch primary; diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java index d6e06e5bc77..ff5403be9d6 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -42,7 +42,7 @@ import org.springframework.lang.Nullable; * @since 2.0 */ @SuppressWarnings("serial") -class InstantiationModelAwarePointcutAdvisorImpl +final class InstantiationModelAwarePointcutAdvisorImpl implements InstantiationModelAwarePointcutAdvisor, AspectJPrecedenceInformation, Serializable { private static final Advice EMPTY_ADVICE = new Advice() {}; @@ -264,7 +264,7 @@ class InstantiationModelAwarePointcutAdvisorImpl * Note that this is a dynamic pointcut. Otherwise it might * be optimized out if it does not at first match statically. */ - private class PerTargetInstantiationModelPointcut extends DynamicMethodMatcherPointcut { + private final class PerTargetInstantiationModelPointcut extends DynamicMethodMatcherPointcut { private final AspectJExpressionPointcut declaredPointcut; diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/NotAnAtAspectException.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/NotAnAtAspectException.java index 1c45cbc2f65..57ca507d6f8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/NotAnAtAspectException.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/NotAnAtAspectException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.aop.framework.AopConfigException; @SuppressWarnings("serial") public class NotAnAtAspectException extends AopConfigException { - private Class nonAspectClass; + private final Class nonAspectClass; /** diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java index 0807cf47998..d2345e9b282 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java @@ -27,13 +27,17 @@ import org.springframework.lang.Nullable; * @author Ramnivas Laddad * @since 2.5 */ -public class ProxyCreationContext { +public final class ProxyCreationContext { /** ThreadLocal holding the current proxied bean name during Advisor matching. */ private static final ThreadLocal currentProxiedBeanName = new NamedThreadLocal<>("Name of currently proxied bean"); + private ProxyCreationContext() { + } + + /** * Return the name of the currently proxied bean instance. * @return the name of the bean, or {@code null} if none available diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java index d36ce8ad07a..8770607af2d 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java @@ -41,7 +41,7 @@ import org.springframework.core.PriorityOrdered; * @author Juergen Hoeller */ @SuppressWarnings("serial") -public class ExposeInvocationInterceptor implements MethodInterceptor, PriorityOrdered, Serializable { +public final class ExposeInvocationInterceptor implements MethodInterceptor, PriorityOrdered, Serializable { /** Singleton instance of this class. */ public static final ExposeInvocationInterceptor INSTANCE = new ExposeInvocationInterceptor(); diff --git a/spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java index 4dd24146a3e..4cb20236b12 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java @@ -30,7 +30,7 @@ import org.springframework.util.ObjectUtils; * @author Rod Johnson * @author Juergen Hoeller */ -public class EmptyTargetSource implements TargetSource, Serializable { +public final class EmptyTargetSource implements TargetSource, Serializable { /** use serialVersionUID from Spring 1.2 for interoperability. */ private static final long serialVersionUID = 3680494563553489691L; diff --git a/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnyThrow.java b/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnyThrow.java index d391c0a6bc8..167cff4a437 100644 --- a/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnyThrow.java +++ b/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnyThrow.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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,11 @@ package org.springframework.cache.aspectj; * * @author Stephane Nicoll */ -class AnyThrow { +final class AnyThrow { + + private AnyThrow() { + } + static void throwUnchecked(Throwable e) { AnyThrow.throwAny(e); diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java b/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java index 4f11119f588..0c23f985407 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,13 +31,13 @@ import org.springframework.lang.Nullable; @SuppressWarnings("serial") public class BeanInstantiationException extends FatalBeanException { - private Class beanClass; + private final Class beanClass; @Nullable - private Constructor constructor; + private final Constructor constructor; @Nullable - private Method constructingMethod; + private final Method constructingMethod; /** @@ -58,6 +58,8 @@ public class BeanInstantiationException extends FatalBeanException { public BeanInstantiationException(Class beanClass, String msg, @Nullable Throwable cause) { super("Failed to instantiate [" + beanClass.getName() + "]: " + msg, cause); this.beanClass = beanClass; + this.constructor = null; + this.constructingMethod = null; } /** @@ -71,6 +73,7 @@ public class BeanInstantiationException extends FatalBeanException { super("Failed to instantiate [" + constructor.getDeclaringClass().getName() + "]: " + msg, cause); this.beanClass = constructor.getDeclaringClass(); this.constructor = constructor; + this.constructingMethod = null; } /** @@ -84,6 +87,7 @@ public class BeanInstantiationException extends FatalBeanException { public BeanInstantiationException(Method constructingMethod, String msg, @Nullable Throwable cause) { super("Failed to instantiate [" + constructingMethod.getReturnType().getName() + "]: " + msg, cause); this.beanClass = constructingMethod.getReturnType(); + this.constructor = null; this.constructingMethod = constructingMethod; } diff --git a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java index 2659293560f..e327916ff50 100644 --- a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java +++ b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java @@ -71,7 +71,7 @@ import org.springframework.util.StringUtils; * @see #clearClassLoader(ClassLoader) * @see #forClass(Class) */ -public class CachedIntrospectionResults { +public final class CachedIntrospectionResults { /** * System property that instructs Spring to use the {@link Introspector#IGNORE_ALL_BEANINFO} diff --git a/spring-beans/src/main/java/org/springframework/beans/InvalidPropertyException.java b/spring-beans/src/main/java/org/springframework/beans/InvalidPropertyException.java index 8cb12141308..0600580a679 100644 --- a/spring-beans/src/main/java/org/springframework/beans/InvalidPropertyException.java +++ b/spring-beans/src/main/java/org/springframework/beans/InvalidPropertyException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,9 +28,9 @@ import org.springframework.lang.Nullable; @SuppressWarnings("serial") public class InvalidPropertyException extends FatalBeanException { - private Class beanClass; + private final Class beanClass; - private String propertyName; + private final String propertyName; /** diff --git a/spring-beans/src/main/java/org/springframework/beans/NotWritablePropertyException.java b/spring-beans/src/main/java/org/springframework/beans/NotWritablePropertyException.java index 1399c69e6cf..be43e1ac1e9 100644 --- a/spring-beans/src/main/java/org/springframework/beans/NotWritablePropertyException.java +++ b/spring-beans/src/main/java/org/springframework/beans/NotWritablePropertyException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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,7 +30,7 @@ import org.springframework.lang.Nullable; public class NotWritablePropertyException extends InvalidPropertyException { @Nullable - private String[] possibleMatches; + private final String[] possibleMatches; /** @@ -42,6 +42,7 @@ public class NotWritablePropertyException extends InvalidPropertyException { super(beanClass, propertyName, "Bean property '" + propertyName + "' is not writable or has an invalid setter method: " + "Does the return type of the getter match the parameter type of the setter?"); + this.possibleMatches = null; } /** @@ -52,6 +53,7 @@ public class NotWritablePropertyException extends InvalidPropertyException { */ public NotWritablePropertyException(Class beanClass, String propertyName, String msg) { super(beanClass, propertyName, msg); + this.possibleMatches = null; } /** @@ -63,6 +65,7 @@ public class NotWritablePropertyException extends InvalidPropertyException { */ public NotWritablePropertyException(Class beanClass, String propertyName, String msg, Throwable cause) { super(beanClass, propertyName, msg, cause); + this.possibleMatches = null; } /** diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyAccessException.java b/spring-beans/src/main/java/org/springframework/beans/PropertyAccessException.java index bceb1c2e61d..e2af5cafab7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyAccessException.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyAccessException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.springframework.lang.Nullable; public abstract class PropertyAccessException extends BeansException { @Nullable - private transient PropertyChangeEvent propertyChangeEvent; + private final PropertyChangeEvent propertyChangeEvent; /** @@ -52,6 +52,7 @@ public abstract class PropertyAccessException extends BeansException { */ public PropertyAccessException(String msg, @Nullable Throwable cause) { super(msg, cause); + this.propertyChangeEvent = null; } diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyBatchUpdateException.java b/spring-beans/src/main/java/org/springframework/beans/PropertyBatchUpdateException.java index 943deabe33f..c5030c728a8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyBatchUpdateException.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyBatchUpdateException.java @@ -40,7 +40,7 @@ import org.springframework.util.ObjectUtils; public class PropertyBatchUpdateException extends BeansException { /** List of PropertyAccessException objects. */ - private PropertyAccessException[] propertyAccessExceptions; + private final PropertyAccessException[] propertyAccessExceptions; /** diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java index 773d06542d5..9e1120dd50c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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,7 +30,12 @@ import org.springframework.util.ObjectUtils; * @author Chris Beams * @author Juergen Hoeller */ -class PropertyDescriptorUtils { +final class PropertyDescriptorUtils { + + + private PropertyDescriptorUtils() { + } + /** * See {@link java.beans.FeatureDescriptor}. diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java index 4f2528d6019..50ef8485041 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java @@ -517,7 +517,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * Holder for a registered custom editor with property name. * Keeps the PropertyEditor itself plus the type it was registered for. */ - private static class CustomEditorHolder { + private static final class CustomEditorHolder { private final PropertyEditor propertyEditor; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java index cb968c736b9..4b98aaddd98 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java @@ -35,10 +35,10 @@ import org.springframework.lang.Nullable; public class BeanCreationException extends FatalBeanException { @Nullable - private String beanName; + private final String beanName; @Nullable - private String resourceDescription; + private final String resourceDescription; @Nullable private List relatedCauses; @@ -50,6 +50,8 @@ public class BeanCreationException extends FatalBeanException { */ public BeanCreationException(String msg) { super(msg); + this.beanName = null; + this.resourceDescription = null; } /** @@ -59,6 +61,8 @@ public class BeanCreationException extends FatalBeanException { */ public BeanCreationException(String msg, Throwable cause) { super(msg, cause); + this.beanName = null; + this.resourceDescription = null; } /** @@ -69,6 +73,7 @@ public class BeanCreationException extends FatalBeanException { public BeanCreationException(String beanName, String msg) { super("Error creating bean with name '" + beanName + "': " + msg); this.beanName = beanName; + this.resourceDescription = null; } /** @@ -94,6 +99,7 @@ public class BeanCreationException extends FatalBeanException { (resourceDescription != null ? " defined in " + resourceDescription : "") + ": " + msg); this.resourceDescription = resourceDescription; this.beanName = beanName; + this.relatedCauses = null; } /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanDefinitionStoreException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanDefinitionStoreException.java index 44c23a3de83..2f8b5d3321c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanDefinitionStoreException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanDefinitionStoreException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,10 +31,10 @@ import org.springframework.lang.Nullable; public class BeanDefinitionStoreException extends FatalBeanException { @Nullable - private String resourceDescription; + private final String resourceDescription; @Nullable - private String beanName; + private final String beanName; /** @@ -43,6 +43,8 @@ public class BeanDefinitionStoreException extends FatalBeanException { */ public BeanDefinitionStoreException(String msg) { super(msg); + this.resourceDescription = null; + this.beanName = null; } /** @@ -52,6 +54,8 @@ public class BeanDefinitionStoreException extends FatalBeanException { */ public BeanDefinitionStoreException(String msg, @Nullable Throwable cause) { super(msg, cause); + this.resourceDescription = null; + this.beanName = null; } /** @@ -62,6 +66,7 @@ public class BeanDefinitionStoreException extends FatalBeanException { public BeanDefinitionStoreException(@Nullable String resourceDescription, String msg) { super(msg); this.resourceDescription = resourceDescription; + this.beanName = null; } /** @@ -73,6 +78,7 @@ public class BeanDefinitionStoreException extends FatalBeanException { public BeanDefinitionStoreException(@Nullable String resourceDescription, String msg, @Nullable Throwable cause) { super(msg, cause); this.resourceDescription = resourceDescription; + this.beanName = null; } /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanNotOfRequiredTypeException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanNotOfRequiredTypeException.java index 5e552b861e5..6b07af29a4b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanNotOfRequiredTypeException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanNotOfRequiredTypeException.java @@ -29,13 +29,13 @@ import org.springframework.util.ClassUtils; public class BeanNotOfRequiredTypeException extends BeansException { /** The name of the instance that was of the wrong type. */ - private String beanName; + private final String beanName; /** The required type. */ - private Class requiredType; + private final Class requiredType; /** The offending type. */ - private Class actualType; + private final Class actualType; /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java b/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java index f2a928947df..b8b2a1e3bbd 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,13 +30,13 @@ import org.springframework.lang.Nullable; public class CannotLoadBeanClassException extends FatalBeanException { @Nullable - private String resourceDescription; + private final String resourceDescription; @Nullable - private String beanName; + private final String beanName; @Nullable - private String beanClassName; + private final String beanClassName; /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java b/spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java index 539b2534248..d42cf3befbc 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -36,10 +36,10 @@ import org.springframework.lang.Nullable; public class NoSuchBeanDefinitionException extends BeansException { @Nullable - private String beanName; + private final String beanName; @Nullable - private ResolvableType resolvableType; + private final ResolvableType resolvableType; /** @@ -49,6 +49,7 @@ public class NoSuchBeanDefinitionException extends BeansException { public NoSuchBeanDefinitionException(String name) { super("No bean named '" + name + "' available"); this.beanName = name; + this.resolvableType = null; } /** @@ -59,6 +60,7 @@ public class NoSuchBeanDefinitionException extends BeansException { public NoSuchBeanDefinitionException(String name, String message) { super("No bean named '" + name + "' available: " + message); this.beanName = name; + this.resolvableType = null; } /** @@ -85,6 +87,7 @@ public class NoSuchBeanDefinitionException extends BeansException { */ public NoSuchBeanDefinitionException(ResolvableType type) { super("No qualifying bean of type '" + type + "' available"); + this.beanName = null; this.resolvableType = type; } @@ -96,6 +99,7 @@ public class NoSuchBeanDefinitionException extends BeansException { */ public NoSuchBeanDefinitionException(ResolvableType type, String message) { super("No qualifying bean of type '" + type + "' available: " + message); + this.beanName = null; this.resolvableType = type; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/NoUniqueBeanDefinitionException.java b/spring-beans/src/main/java/org/springframework/beans/factory/NoUniqueBeanDefinitionException.java index 1652dce7ebc..d7ebe487ab2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/NoUniqueBeanDefinitionException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/NoUniqueBeanDefinitionException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -33,10 +33,10 @@ import org.springframework.util.StringUtils; @SuppressWarnings("serial") public class NoUniqueBeanDefinitionException extends NoSuchBeanDefinitionException { - private int numberOfBeansFound; + private final int numberOfBeansFound; @Nullable - private Collection beanNamesFound; + private final Collection beanNamesFound; /** @@ -48,6 +48,7 @@ public class NoUniqueBeanDefinitionException extends NoSuchBeanDefinitionExcepti public NoUniqueBeanDefinitionException(Class type, int numberOfBeansFound, String message) { super(type, message); this.numberOfBeansFound = numberOfBeansFound; + this.beanNamesFound = null; } /** @@ -56,8 +57,9 @@ public class NoUniqueBeanDefinitionException extends NoSuchBeanDefinitionExcepti * @param beanNamesFound the names of all matching beans (as a Collection) */ public NoUniqueBeanDefinitionException(Class type, Collection beanNamesFound) { - this(type, beanNamesFound.size(), "expected single matching bean but found " + beanNamesFound.size() + ": " + + super(type, "expected single matching bean but found " + beanNamesFound.size() + ": " + StringUtils.collectionToCommaDelimitedString(beanNamesFound)); + this.numberOfBeansFound = beanNamesFound.size(); this.beanNamesFound = beanNamesFound; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java b/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java index a5de119729c..4a39985acbc 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -33,7 +33,7 @@ import org.springframework.util.StringUtils; public class UnsatisfiedDependencyException extends BeanCreationException { @Nullable - private InjectionPoint injectionPoint; + private final InjectionPoint injectionPoint; /** @@ -49,6 +49,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException { super(resourceDescription, beanName, "Unsatisfied dependency expressed through bean property '" + propertyName + "'" + (StringUtils.hasLength(msg) ? ": " + msg : "")); + this.injectionPoint = null; } /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java index 34fe7ec5f5b..c6af2b7dcfe 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -250,7 +250,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport } - private class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver { + private final class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver { private final Properties props; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java index 8a28c97956d..170f394648b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.springframework.util.ObjectUtils; * @author Juergen Hoeller * @since 2.0 */ -public class BeanDefinitionBuilder { +public final class BeanDefinitionBuilder { /** * Create a new {@code BeanDefinitionBuilder} used to construct a {@link GenericBeanDefinition}. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java index 1098273a3d7..144176d3300 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import org.springframework.util.StringUtils; * @see PropertiesBeanDefinitionReader * @see org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader */ -public class BeanDefinitionReaderUtils { +public final class BeanDefinitionReaderUtils { /** * Separator for generated bean names. If a class name or parent name is not @@ -44,6 +44,10 @@ public class BeanDefinitionReaderUtils { public static final String GENERATED_BEAN_NAME_SEPARATOR = BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR; + private BeanDefinitionReaderUtils() { + } + + /** * Create a new GenericBeanDefinition for the given parent name and class name, * eagerly loading the bean class if a ClassLoader has been specified. diff --git a/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java b/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java index 6635f51bb89..d830aefab10 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java +++ b/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java @@ -37,7 +37,7 @@ public class MailSendException extends MailException { private final transient Map failedMessages; @Nullable - private Exception[] messageExceptions; + private final Exception[] messageExceptions; /** @@ -56,6 +56,7 @@ public class MailSendException extends MailException { public MailSendException(String msg, @Nullable Throwable cause) { super(msg, cause); this.failedMessages = new LinkedHashMap<>(); + this.messageExceptions = null; } /** diff --git a/spring-context/src/main/java/org/springframework/cache/config/CacheManagementConfigUtils.java b/spring-context/src/main/java/org/springframework/cache/config/CacheManagementConfigUtils.java index 0dcbb9838e9..ffddc844f24 100644 --- a/spring-context/src/main/java/org/springframework/cache/config/CacheManagementConfigUtils.java +++ b/spring-context/src/main/java/org/springframework/cache/config/CacheManagementConfigUtils.java @@ -22,7 +22,7 @@ package org.springframework.cache.config; * @author Juergen Hoeller * @since 4.1 */ -public class CacheManagementConfigUtils { +public final class CacheManagementConfigUtils { /** * The name of the cache advisor bean. @@ -48,4 +48,8 @@ public class CacheManagementConfigUtils { public static final String JCACHE_ASPECT_BEAN_NAME = "org.springframework.cache.config.internalJCacheAspect"; + + private CacheManagementConfigUtils() { + } + } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java index 5a32e6c1443..3e3cd9bce94 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java @@ -60,7 +60,7 @@ import org.springframework.util.ClassUtils; * @see org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor * @see org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor */ -public class AnnotationConfigUtils { +public final class AnnotationConfigUtils { /** * The bean name of the internally managed Configuration annotation processor. @@ -127,6 +127,10 @@ public class AnnotationConfigUtils { ClassUtils.isPresent(PERSISTENCE_ANNOTATION_PROCESSOR_CLASS_NAME, AnnotationConfigUtils.class.getClassLoader()); + private AnnotationConfigUtils() { + } + + /** * Register all relevant annotation post processors in the given registry. * @param registry the registry to operate on diff --git a/spring-context/src/main/java/org/springframework/context/annotation/BeanAnnotationHelper.java b/spring-context/src/main/java/org/springframework/context/annotation/BeanAnnotationHelper.java index b28ab0492b6..d54a19c85d7 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/BeanAnnotationHelper.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/BeanAnnotationHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,12 @@ import org.springframework.core.annotation.AnnotatedElementUtils; * @author Juergen Hoeller * @since 3.1 */ -class BeanAnnotationHelper { +final class BeanAnnotationHelper { + + + private BeanAnnotationHelper() { + } + public static boolean isBeanAnnotated(Method method) { return AnnotatedElementUtils.hasAnnotation(method, Bean.class); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ScopedProxyCreator.java b/spring-context/src/main/java/org/springframework/context/annotation/ScopedProxyCreator.java index 371c8b66741..58e9b0b0b29 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ScopedProxyCreator.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ScopedProxyCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,12 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; * @since 3.0 * @see org.springframework.aop.scope.ScopedProxyUtils#createScopedProxy */ -class ScopedProxyCreator { +final class ScopedProxyCreator { + + + private ScopedProxyCreator() { + } + public static BeanDefinitionHolder createScopedProxy( BeanDefinitionHolder definitionHolder, BeanDefinitionRegistry registry, boolean proxyTargetClass) { diff --git a/spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndexLoader.java b/spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndexLoader.java index 02d85b9a49b..90a9400032e 100644 --- a/spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndexLoader.java +++ b/spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndexLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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,7 +39,7 @@ import org.springframework.util.ConcurrentReferenceHashMap; * @author Stephane Nicoll * @since 5.0 */ -public class CandidateComponentsIndexLoader { +public final class CandidateComponentsIndexLoader { /** * The location to look for components. @@ -67,6 +67,10 @@ public class CandidateComponentsIndexLoader { new ConcurrentReferenceHashMap<>(); + private CandidateComponentsIndexLoader() { + } + + /** * Load and instantiate the {@link CandidateComponentsIndex} from * {@value #COMPONENTS_RESOURCE_LOCATION}, using the given class loader. If no diff --git a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java index a316814ed2c..691d68e43de 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java +++ b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java @@ -48,7 +48,12 @@ import org.springframework.lang.Nullable; * @author Juergen Hoeller * @since 4.0 */ -class PostProcessorRegistrationDelegate { +final class PostProcessorRegistrationDelegate { + + + private PostProcessorRegistrationDelegate() { + } + public static void invokeBeanFactoryPostProcessors( ConfigurableListableBeanFactory beanFactory, List beanFactoryPostProcessors) { diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java index 7b6148d9ba3..0a6757ff8be 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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,6 +38,10 @@ public final class JodaTimeContextHolder { new NamedThreadLocal<>("JodaTimeContext"); + private JodaTimeContextHolder() { + } + + /** * Reset the JodaTimeContext for the current thread. */ diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java index 6d3435befcd..c0c66cc39a6 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeConverters.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2018 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,6 +46,11 @@ import org.springframework.format.datetime.DateFormatterRegistrar; */ final class JodaTimeConverters { + + private JodaTimeConverters() { + } + + /** * Install the converters into the converter registry. * @param registry the converter registry diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java index 44546c7a69c..cdb6df3744f 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,10 @@ public final class DateTimeContextHolder { new NamedThreadLocal<>("DateTimeContext"); + private DateTimeContextHolder() { + } + + /** * Reset the DateTimeContext for the current thread. */ diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeConverters.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeConverters.java index 26808fb6aac..e073e864824 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeConverters.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeConverters.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -43,6 +43,11 @@ import org.springframework.format.datetime.DateFormatterRegistrar; */ final class DateTimeConverters { + + private DateTimeConverters() { + } + + /** * Install the converters into the converter registry. * @param registry the converter registry diff --git a/spring-context/src/main/java/org/springframework/jmx/support/ObjectNameManager.java b/spring-context/src/main/java/org/springframework/jmx/support/ObjectNameManager.java index cf63334eeee..70e822cab4a 100644 --- a/spring-context/src/main/java/org/springframework/jmx/support/ObjectNameManager.java +++ b/spring-context/src/main/java/org/springframework/jmx/support/ObjectNameManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,12 @@ import javax.management.ObjectName; * @since 1.2 * @see javax.management.ObjectName#getInstance(String) */ -public class ObjectNameManager { +public final class ObjectNameManager { + + + private ObjectNameManager() { + } + /** * Retrieve the {@code ObjectName} instance corresponding to the supplied name. diff --git a/spring-context/src/main/java/org/springframework/scheduling/config/TaskManagementConfigUtils.java b/spring-context/src/main/java/org/springframework/scheduling/config/TaskManagementConfigUtils.java index 7b0013f729e..47c6d5dfd1c 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/config/TaskManagementConfigUtils.java +++ b/spring-context/src/main/java/org/springframework/scheduling/config/TaskManagementConfigUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2018 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,7 @@ package org.springframework.scheduling.config; * @author Juergen Hoeller * @since 4.1 */ -public class TaskManagementConfigUtils { +public final class TaskManagementConfigUtils { /** * The bean name of the internally managed Scheduled annotation processor. @@ -42,4 +42,9 @@ public class TaskManagementConfigUtils { public static final String ASYNC_EXECUTION_ASPECT_BEAN_NAME = "org.springframework.scheduling.config.internalAsyncExecutionAspect"; + + private TaskManagementConfigUtils() { + } + + } diff --git a/spring-context/src/main/java/org/springframework/scripting/ScriptCompilationException.java b/spring-context/src/main/java/org/springframework/scripting/ScriptCompilationException.java index 0333c6d2633..cb3d9dcd315 100644 --- a/spring-context/src/main/java/org/springframework/scripting/ScriptCompilationException.java +++ b/spring-context/src/main/java/org/springframework/scripting/ScriptCompilationException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.lang.Nullable; public class ScriptCompilationException extends NestedRuntimeException { @Nullable - private ScriptSource scriptSource; + private final ScriptSource scriptSource; /** @@ -38,6 +38,7 @@ public class ScriptCompilationException extends NestedRuntimeException { */ public ScriptCompilationException(String msg) { super(msg); + this.scriptSource = null; } /** @@ -47,6 +48,7 @@ public class ScriptCompilationException extends NestedRuntimeException { */ public ScriptCompilationException(String msg, Throwable cause) { super(msg, cause); + this.scriptSource = null; } /** diff --git a/spring-context/src/main/java/org/springframework/scripting/bsh/BshScriptUtils.java b/spring-context/src/main/java/org/springframework/scripting/bsh/BshScriptUtils.java index b5a59ef64f1..014704cf19b 100644 --- a/spring-context/src/main/java/org/springframework/scripting/bsh/BshScriptUtils.java +++ b/spring-context/src/main/java/org/springframework/scripting/bsh/BshScriptUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -225,7 +225,7 @@ public abstract class BshScriptUtils { * Exception to be thrown on script execution failure. */ @SuppressWarnings("serial") - public static class BshExecutionException extends NestedRuntimeException { + public static final class BshExecutionException extends NestedRuntimeException { private BshExecutionException(EvalError ex) { super("BeanShell script execution failed", ex); diff --git a/spring-core/src/main/java/org/springframework/core/ReactiveTypeDescriptor.java b/spring-core/src/main/java/org/springframework/core/ReactiveTypeDescriptor.java index 8cfb7c62a9d..494d722ad31 100644 --- a/spring-core/src/main/java/org/springframework/core/ReactiveTypeDescriptor.java +++ b/spring-core/src/main/java/org/springframework/core/ReactiveTypeDescriptor.java @@ -28,7 +28,7 @@ import org.springframework.util.Assert; * @author Rossen Stoyanchev * @since 5.0 */ -public class ReactiveTypeDescriptor { +public final class ReactiveTypeDescriptor { private final Class reactiveType; diff --git a/spring-core/src/main/java/org/springframework/core/SpringVersion.java b/spring-core/src/main/java/org/springframework/core/SpringVersion.java index a8c7fcead50..13cf4f49e46 100644 --- a/spring-core/src/main/java/org/springframework/core/SpringVersion.java +++ b/spring-core/src/main/java/org/springframework/core/SpringVersion.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,12 @@ import org.springframework.lang.Nullable; * @author Juergen Hoeller * @since 1.1 */ -public class SpringVersion { +public final class SpringVersion { + + + private SpringVersion() { + } + /** * Return the full version string of the present Spring codebase, diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index 36cec0a858f..28e07be2fe6 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -2047,7 +2047,7 @@ public abstract class AnnotationUtils { * @see #getAttributeAliasNames * @see #getAttributeOverrideName */ - private static class AliasDescriptor { + private static final class AliasDescriptor { private final Method sourceAttribute; diff --git a/spring-core/src/main/java/org/springframework/core/codec/CharSequenceEncoder.java b/spring-core/src/main/java/org/springframework/core/codec/CharSequenceEncoder.java index c0491e540d5..e40dee6a4cf 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/CharSequenceEncoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/CharSequenceEncoder.java @@ -42,7 +42,7 @@ import org.springframework.util.MimeTypeUtils; * @since 5.0 * @see StringDecoder */ -public class CharSequenceEncoder extends AbstractEncoder { +public final class CharSequenceEncoder extends AbstractEncoder { /** * The default charset used by the encoder. diff --git a/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java b/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java index 97efd6984e0..d9a2535fa33 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java @@ -53,7 +53,7 @@ import org.springframework.util.MimeTypeUtils; * @since 5.0 * @see CharSequenceEncoder */ -public class StringDecoder extends AbstractDataBufferDecoder { +public final class StringDecoder extends AbstractDataBufferDecoder { private static final DataBuffer END_FRAME = new DefaultDataBufferFactory().wrap(new byte[0]); diff --git a/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java b/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java index 9a18ee799f0..268a3cfdbdc 100644 --- a/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java +++ b/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java @@ -31,7 +31,10 @@ import org.springframework.util.StringUtils; * @author Phillip Webb * @since 5.1 */ -class ProfilesParser { +final class ProfilesParser { + + private ProfilesParser() { + } static Profiles parse(String... expressions) { Assert.notEmpty(expressions, "Must specify at least one profile"); diff --git a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java index 38c30cd1368..a04f1739404 100644 --- a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java @@ -57,6 +57,27 @@ public abstract class ReflectionUtils { private static final Field[] NO_FIELDS = {}; + /** + * Pre-built FieldFilter that matches all non-static, non-final fields. + */ + public static final FieldFilter COPYABLE_FIELDS = + field -> !(Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers())); + + + /** + * Pre-built MethodFilter that matches all non-bridge methods. + */ + public static final MethodFilter NON_BRIDGED_METHODS = + (method -> !method.isBridge()); + + + /** + * Pre-built MethodFilter that matches all non-bridge non-synthetic methods + * which are not declared on {@code java.lang.Object}. + */ + public static final MethodFilter USER_DECLARED_METHODS = + (method -> (!method.isBridge() && !method.isSynthetic() && method.getDeclaringClass() != Object.class)); + /** * Cache for {@link Class#getDeclaredMethods()} plus equivalent default methods @@ -847,25 +868,4 @@ public abstract class ReflectionUtils { } - /** - * Pre-built FieldFilter that matches all non-static, non-final fields. - */ - public static final FieldFilter COPYABLE_FIELDS = - field -> !(Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers())); - - - /** - * Pre-built MethodFilter that matches all non-bridge methods. - */ - public static final MethodFilter NON_BRIDGED_METHODS = - (method -> !method.isBridge()); - - - /** - * Pre-built MethodFilter that matches all non-bridge non-synthetic methods - * which are not declared on {@code java.lang.Object}. - */ - public static final MethodFilter USER_DECLARED_METHODS = - (method -> (!method.isBridge() && !method.isSynthetic() && method.getDeclaringClass() != Object.class)); - } diff --git a/spring-expression/src/main/java/org/springframework/expression/ExpressionException.java b/spring-expression/src/main/java/org/springframework/expression/ExpressionException.java index 9a3133fce1f..2ca880ed47b 100644 --- a/spring-expression/src/main/java/org/springframework/expression/ExpressionException.java +++ b/spring-expression/src/main/java/org/springframework/expression/ExpressionException.java @@ -29,7 +29,7 @@ import org.springframework.lang.Nullable; public class ExpressionException extends RuntimeException { @Nullable - protected String expressionString; + protected final String expressionString; protected int position; // -1 if not known; should be known in all reasonable cases @@ -40,6 +40,8 @@ public class ExpressionException extends RuntimeException { */ public ExpressionException(String message) { super(message); + this.expressionString = null; + this.position = 0; } /** @@ -49,6 +51,8 @@ public class ExpressionException extends RuntimeException { */ public ExpressionException(String message, Throwable cause) { super(message, cause); + this.expressionString = null; + this.position = 0; } /** @@ -81,6 +85,7 @@ public class ExpressionException extends RuntimeException { */ public ExpressionException(int position, String message) { super(message); + this.expressionString = null; this.position = position; } @@ -92,6 +97,7 @@ public class ExpressionException extends RuntimeException { */ public ExpressionException(int position, String message, Throwable cause) { super(message, cause); + this.expressionString = null; this.position = position; } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java index 19127b5a3b9..69797f9697b 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java @@ -1009,6 +1009,21 @@ public class CodeFlow implements Opcodes { } } + public static final String toBoxedDescriptor(String primitiveDescriptor) { + switch (primitiveDescriptor.charAt(0)) { + case 'I': return "Ljava/lang/Integer"; + case 'J': return "Ljava/lang/Long"; + case 'F': return "Ljava/lang/Float"; + case 'D': return "Ljava/lang/Double"; + case 'B': return "Ljava/lang/Byte"; + case 'C': return "Ljava/lang/Character"; + case 'S': return "Ljava/lang/Short"; + case 'Z': return "Ljava/lang/Boolean"; + default: + throw new IllegalArgumentException("Unexpected non primitive descriptor "+primitiveDescriptor); + } + } + /** * Interface used to generate fields. @@ -1029,19 +1044,5 @@ public class CodeFlow implements Opcodes { void generateCode(MethodVisitor mv, CodeFlow codeflow); } - public static String toBoxedDescriptor(String primitiveDescriptor) { - switch (primitiveDescriptor.charAt(0)) { - case 'I': return "Ljava/lang/Integer"; - case 'J': return "Ljava/lang/Long"; - case 'F': return "Ljava/lang/Float"; - case 'D': return "Ljava/lang/Double"; - case 'B': return "Ljava/lang/Byte"; - case 'C': return "Ljava/lang/Character"; - case 'S': return "Ljava/lang/Short"; - case 'Z': return "Ljava/lang/Boolean"; - default: - throw new IllegalArgumentException("Unexpected non primitive descriptor "+primitiveDescriptor); - } - } } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java index ba7d2331b5e..5f5df5be1a6 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java @@ -41,7 +41,7 @@ import org.springframework.util.ObjectUtils; public abstract class Operator extends SpelNodeImpl { private final String operatorName; - + // The descriptors of the runtime operand values are used if the discovered declared // descriptors are not providing enough information (for example a generic type // whose accessors seem to only be returning 'Object' - the actual descriptors may @@ -104,8 +104,8 @@ public abstract class Operator extends SpelNodeImpl { return (dc.areNumbers && dc.areCompatible); } - /** - * Numeric comparison operators share very similar generated code, only differing in + /** + * Numeric comparison operators share very similar generated code, only differing in * two comparison instructions. */ protected void generateComparisonCode(MethodVisitor mv, CodeFlow cf, int compInstruction1, int compInstruction2) { @@ -113,20 +113,20 @@ public abstract class Operator extends SpelNodeImpl { SpelNodeImpl right = getRightOperand(); String leftDesc = left.exitTypeDescriptor; String rightDesc = right.exitTypeDescriptor; - + boolean unboxLeft = !CodeFlow.isPrimitive(leftDesc); boolean unboxRight = !CodeFlow.isPrimitive(rightDesc); DescriptorComparison dc = DescriptorComparison.checkNumericCompatibility( leftDesc, rightDesc, this.leftActualDescriptor, this.rightActualDescriptor); char targetType = dc.compatibleType; // CodeFlow.toPrimitiveTargetDesc(leftDesc); - + cf.enterCompilationScope(); left.generateCode(mv, cf); cf.exitCompilationScope(); if (unboxLeft) { CodeFlow.insertUnboxInsns(mv, targetType, leftDesc); } - + cf.enterCompilationScope(); right.generateCode(mv, cf); cf.exitCompilationScope(); @@ -142,11 +142,11 @@ public abstract class Operator extends SpelNodeImpl { mv.visitJumpInsn(compInstruction1, elseTarget); } else if (targetType == 'F') { - mv.visitInsn(FCMPG); + mv.visitInsn(FCMPG); mv.visitJumpInsn(compInstruction1, elseTarget); } else if (targetType == 'J') { - mv.visitInsn(LCMP); + mv.visitInsn(LCMP); mv.visitJumpInsn(compInstruction1, elseTarget); } else if (targetType == 'I') { @@ -231,13 +231,13 @@ public abstract class Operator extends SpelNodeImpl { return false; } - + /** * A descriptor comparison encapsulates the result of comparing descriptor * for two operands and describes at what level they are compatible. */ - protected static class DescriptorComparison { + protected static final class DescriptorComparison { static final DescriptorComparison NOT_NUMBERS = new DescriptorComparison(false, false, ' '); @@ -254,7 +254,7 @@ public abstract class Operator extends SpelNodeImpl { this.areCompatible = areCompatible; this.compatibleType = compatibleType; } - + /** * Return an object that indicates whether the input descriptors are compatible. *

A declared descriptor is what could statically be determined (e.g. from looking @@ -278,7 +278,7 @@ public abstract class Operator extends SpelNodeImpl { boolean leftNumeric = CodeFlow.isPrimitiveOrUnboxableSupportedNumberOrBoolean(ld); boolean rightNumeric = CodeFlow.isPrimitiveOrUnboxableSupportedNumberOrBoolean(rd); - + // If the declared descriptors aren't providing the information, try the actual descriptors if (!leftNumeric && !ObjectUtils.nullSafeEquals(ld, leftActualDescriptor)) { ld = leftActualDescriptor; @@ -288,7 +288,7 @@ public abstract class Operator extends SpelNodeImpl { rd = rightActualDescriptor; rightNumeric = CodeFlow.isPrimitiveOrUnboxableSupportedNumberOrBoolean(rd); } - + if (leftNumeric && rightNumeric) { if (CodeFlow.areBoxingCompatible(ld, rd)) { return new DescriptorComparison(true, true, CodeFlow.toPrimitiveTargetDesc(ld)); @@ -299,7 +299,7 @@ public abstract class Operator extends SpelNodeImpl { } else { return DescriptorComparison.NOT_NUMBERS; - } + } } } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java index 56589819fa7..5acf05d0b83 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -64,7 +64,7 @@ import org.springframework.util.ReflectionUtils; * @author Andy Clement * @since 4.1 */ -public class SpelCompiler implements Opcodes { +public final class SpelCompiler implements Opcodes { private static final Log logger = LogFactory.getLog(SpelCompiler.class); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/BooleanTypedValue.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/BooleanTypedValue.java index 7403ce5e5f9..908d38aff93 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/BooleanTypedValue.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/BooleanTypedValue.java @@ -24,7 +24,7 @@ import org.springframework.expression.TypedValue; * @author Andy Clement * @since 3.0 */ -public class BooleanTypedValue extends TypedValue { +public final class BooleanTypedValue extends TypedValue { /** * True. diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/DataBindingMethodResolver.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/DataBindingMethodResolver.java index c5db421c6d6..114191ffd9f 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/DataBindingMethodResolver.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/DataBindingMethodResolver.java @@ -39,7 +39,7 @@ import org.springframework.lang.Nullable; * @see #forInstanceMethodInvocation() * @see DataBindingPropertyAccessor */ -public class DataBindingMethodResolver extends ReflectiveMethodResolver { +public final class DataBindingMethodResolver extends ReflectiveMethodResolver { private DataBindingMethodResolver() { super(); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/DataBindingPropertyAccessor.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/DataBindingPropertyAccessor.java index 8ee7ec946d1..2b6d966fe16 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/DataBindingPropertyAccessor.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/DataBindingPropertyAccessor.java @@ -37,7 +37,7 @@ import java.lang.reflect.Method; * @see StandardEvaluationContext * @see ReflectivePropertyAccessor */ -public class DataBindingPropertyAccessor extends ReflectivePropertyAccessor { +public final class DataBindingPropertyAccessor extends ReflectivePropertyAccessor { /** * Create a new property accessor for reading and possibly also writing. diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/SimpleEvaluationContext.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/SimpleEvaluationContext.java index a1f9251c118..d27a442f197 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/SimpleEvaluationContext.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/SimpleEvaluationContext.java @@ -86,7 +86,7 @@ import org.springframework.lang.Nullable; * @see StandardTypeConverter * @see DataBindingPropertyAccessor */ -public class SimpleEvaluationContext implements EvaluationContext { +public final class SimpleEvaluationContext implements EvaluationContext { private static final TypeLocator typeNotFoundTypeLocator = typeName -> { throw new SpelEvaluationException(SpelMessage.TYPE_NOT_FOUND, typeName); diff --git a/spring-instrument/src/main/java/org/springframework/instrument/InstrumentationSavingAgent.java b/spring-instrument/src/main/java/org/springframework/instrument/InstrumentationSavingAgent.java index 18e6c33ebe8..cb58e4f63fd 100644 --- a/spring-instrument/src/main/java/org/springframework/instrument/InstrumentationSavingAgent.java +++ b/spring-instrument/src/main/java/org/springframework/instrument/InstrumentationSavingAgent.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,11 +27,15 @@ import java.lang.instrument.Instrumentation; * @since 2.0 * @see org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver */ -public class InstrumentationSavingAgent { +public final class InstrumentationSavingAgent { private static volatile Instrumentation instrumentation; + private InstrumentationSavingAgent() { + } + + /** * Save the {@link Instrumentation} interface exposed by the JVM. */ diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/BadSqlGrammarException.java b/spring-jdbc/src/main/java/org/springframework/jdbc/BadSqlGrammarException.java index 41b0b6f545b..00846daf94d 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/BadSqlGrammarException.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/BadSqlGrammarException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.springframework.dao.InvalidDataAccessResourceUsageException; @SuppressWarnings("serial") public class BadSqlGrammarException extends InvalidDataAccessResourceUsageException { - private String sql; + private final String sql; /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/IncorrectResultSetColumnCountException.java b/spring-jdbc/src/main/java/org/springframework/jdbc/IncorrectResultSetColumnCountException.java index 00eaa7dbca8..0833b76405b 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/IncorrectResultSetColumnCountException.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/IncorrectResultSetColumnCountException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,9 +29,9 @@ import org.springframework.dao.DataRetrievalFailureException; @SuppressWarnings("serial") public class IncorrectResultSetColumnCountException extends DataRetrievalFailureException { - private int expectedCount; + private final int expectedCount; - private int actualCount; + private final int actualCount; /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/InvalidResultSetAccessException.java b/spring-jdbc/src/main/java/org/springframework/jdbc/InvalidResultSetAccessException.java index 0089a1aecb4..3dc8881d251 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/InvalidResultSetAccessException.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/InvalidResultSetAccessException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ import org.springframework.lang.Nullable; public class InvalidResultSetAccessException extends InvalidDataAccessResourceUsageException { @Nullable - private String sql; + private final String sql; /** @@ -57,6 +57,7 @@ public class InvalidResultSetAccessException extends InvalidDataAccessResourceUs */ public InvalidResultSetAccessException(SQLException ex) { super(ex.getMessage(), ex); + this.sql = null; } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/JdbcUpdateAffectedIncorrectNumberOfRowsException.java b/spring-jdbc/src/main/java/org/springframework/jdbc/JdbcUpdateAffectedIncorrectNumberOfRowsException.java index 16be7b0235b..14a282af080 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/JdbcUpdateAffectedIncorrectNumberOfRowsException.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/JdbcUpdateAffectedIncorrectNumberOfRowsException.java @@ -30,10 +30,10 @@ import org.springframework.dao.IncorrectUpdateSemanticsDataAccessException; public class JdbcUpdateAffectedIncorrectNumberOfRowsException extends IncorrectUpdateSemanticsDataAccessException { /** Number of rows that should have been affected. */ - private int expected; + private final int expected; /** Number of rows that actually were affected. */ - private int actual; + private final int actual; /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java index 336ed216e77..38f32fc8786 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java @@ -38,7 +38,12 @@ import org.springframework.util.xml.DomUtils; * @author Stephane Nicoll * @since 3.1 */ -class DatabasePopulatorConfigUtils { +final class DatabasePopulatorConfigUtils { + + + private DatabasePopulatorConfigUtils() { + } + public static void setDatabasePopulator(Element element, BeanDefinitionBuilder builder) { List scripts = DomUtils.getChildElementsByTagName(element, "script"); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java index ce672e4d295..56b5c26e05b 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java @@ -35,7 +35,7 @@ import org.springframework.jdbc.support.MetaDataAccessException; * @author Juergen Hoeller * @since 2.5 */ -public class CallMetaDataProviderFactory { +public final class CallMetaDataProviderFactory { /** List of supported database products for procedure calls. */ public static final List supportedDatabaseProductsForProcedures = Arrays.asList( @@ -59,6 +59,10 @@ public class CallMetaDataProviderFactory { private static final Log logger = LogFactory.getLog(CallMetaDataProviderFactory.class); + private CallMetaDataProviderFactory() { + } + + /** * Create a {@link CallMetaDataProvider} based on the database meta-data. * @param dataSource the JDBC DataSource to use for retrieving meta-data diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java index 22670788d30..9481577c93d 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java @@ -32,11 +32,15 @@ import org.springframework.jdbc.support.MetaDataAccessException; * @author Thomas Risberg * @since 2.5 */ -public class TableMetaDataProviderFactory { +public final class TableMetaDataProviderFactory { private static final Log logger = LogFactory.getLog(TableMetaDataProviderFactory.class); + private TableMetaDataProviderFactory() { + } + + /** * Create a {@link TableMetaDataProvider} based on the database meta-data. * @param dataSource used to retrieve meta-data diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java index 8e7f58c88bd..9470fbf7e0d 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -202,7 +202,7 @@ public class UserCredentialsDataSourceAdapter extends DelegatingDataSource { /** * Inner class used as ThreadLocal value. */ - private static class JdbcUserCredentials { + private static final class JdbcUserCredentials { public final String username; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseConfigurerFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseConfigurerFactory.java index 531e9ddafa3..a32090aad42 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseConfigurerFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseConfigurerFactory.java @@ -29,6 +29,11 @@ import org.springframework.util.Assert; */ final class EmbeddedDatabaseConfigurerFactory { + + private EmbeddedDatabaseConfigurerFactory() { + } + + /** * Return a configurer instance for the given embedded database type. * @param type the embedded database type (HSQL, H2 or Derby) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/OutputStreamFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/OutputStreamFactory.java index 964c3b33232..31ffda5bf78 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/OutputStreamFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/OutputStreamFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 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,12 @@ import java.io.OutputStream; * @author Juergen Hoeller * @since 3.0 */ -public class OutputStreamFactory { +public final class OutputStreamFactory { + + + private OutputStreamFactory() { + } + /** * Returns an {@link java.io.OutputStream} that ignores all data given to it. diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java index 928f3102731..0b5c571fca3 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -33,7 +33,7 @@ import org.springframework.lang.Nullable; * @since 3.1.1 * @see SQLErrorCodesFactory */ -public class CustomSQLExceptionTranslatorRegistry { +public final class CustomSQLExceptionTranslatorRegistry { private static final Log logger = LogFactory.getLog(CustomSQLExceptionTranslatorRegistry.class); diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java b/spring-jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java index a7bef236cd2..6b2ab0d12db 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -320,17 +320,19 @@ public class UserCredentialsConnectionFactoryAdapter /** * Inner class used as ThreadLocal value. */ - private static class JmsUserCredentials { + private static final class JmsUserCredentials { public final String username; public final String password; + private JmsUserCredentials(String username, String password) { this.username = username; this.password = password; } + @Override public String toString() { return "JmsUserCredentials[username='" + this.username + "',password='" + this.password + "']"; diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolver.java index 8080f8a63d5..b1c3b6b34d2 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolver.java @@ -78,7 +78,7 @@ public class DestinationVariableMethodArgumentResolver extends AbstractNamedValu } - private static class DestinationVariableNamedValueInfo extends NamedValueInfo { + private static final class DestinationVariableNamedValueInfo extends NamedValueInfo { private DestinationVariableNamedValueInfo(DestinationVariable annotation) { super(annotation.value(), true, ValueConstants.DEFAULT_NONE); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolver.java index 425f53a59d8..ce45d7e6455 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2018 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. @@ -106,7 +106,7 @@ public class HeaderMethodArgumentResolver extends AbstractNamedValueMethodArgume } - private static class HeaderNamedValueInfo extends NamedValueInfo { + private static final class HeaderNamedValueInfo extends NamedValueInfo { private HeaderNamedValueInfo(Header annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/MethodArgumentNotValidException.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/MethodArgumentNotValidException.java index e043070fca3..9a724478f3c 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/MethodArgumentNotValidException.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/MethodArgumentNotValidException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.springframework.validation.ObjectError; @SuppressWarnings("serial") public class MethodArgumentNotValidException extends MethodArgumentResolutionException { - private BindingResult bindingResult; + private final BindingResult bindingResult; /** @@ -42,6 +42,7 @@ public class MethodArgumentNotValidException extends MethodArgumentResolutionExc */ public MethodArgumentNotValidException(Message message, MethodParameter parameter) { super(message, parameter); + this.bindingResult = null; } /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java index 1d91b41cc36..e1d1ba15502 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java @@ -577,7 +577,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler private volatile boolean isStompConnected; - private StompConnectionHandler(String sessionId, StompHeaderAccessor connectHeaders) { + protected StompConnectionHandler(String sessionId, StompHeaderAccessor connectHeaders) { this(sessionId, connectHeaders, true); } diff --git a/spring-orm/src/main/java/org/springframework/orm/ObjectOptimisticLockingFailureException.java b/spring-orm/src/main/java/org/springframework/orm/ObjectOptimisticLockingFailureException.java index 65e3b6bbff7..34f38fd8240 100644 --- a/spring-orm/src/main/java/org/springframework/orm/ObjectOptimisticLockingFailureException.java +++ b/spring-orm/src/main/java/org/springframework/orm/ObjectOptimisticLockingFailureException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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,10 +30,10 @@ import org.springframework.lang.Nullable; public class ObjectOptimisticLockingFailureException extends OptimisticLockingFailureException { @Nullable - private Object persistentClass; + private final Object persistentClass; @Nullable - private Object identifier; + private final Object identifier; /** @@ -44,6 +44,8 @@ public class ObjectOptimisticLockingFailureException extends OptimisticLockingFa */ public ObjectOptimisticLockingFailureException(String msg, Throwable cause) { super(msg, cause); + this.persistentClass = null; + this.identifier = null; } /** diff --git a/spring-orm/src/main/java/org/springframework/orm/ObjectRetrievalFailureException.java b/spring-orm/src/main/java/org/springframework/orm/ObjectRetrievalFailureException.java index 77885879d35..8b49e081ec8 100644 --- a/spring-orm/src/main/java/org/springframework/orm/ObjectRetrievalFailureException.java +++ b/spring-orm/src/main/java/org/springframework/orm/ObjectRetrievalFailureException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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,10 +30,10 @@ import org.springframework.lang.Nullable; public class ObjectRetrievalFailureException extends DataRetrievalFailureException { @Nullable - private Object persistentClass; + private final Object persistentClass; @Nullable - private Object identifier; + private final Object identifier; /** @@ -44,6 +44,8 @@ public class ObjectRetrievalFailureException extends DataRetrievalFailureExcepti */ public ObjectRetrievalFailureException(String msg, Throwable cause) { super(msg, cause); + this.persistentClass = null; + this.identifier = null; } /** diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java index 7ecfe11d565..397579c26b5 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java @@ -890,7 +890,7 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana * Holder for suspended resources. * Used internally by {@code doSuspend} and {@code doResume}. */ - private static class SuspendedResourcesHolder { + private static final class SuspendedResourcesHolder { private final SessionHolder sessionHolder; diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java b/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java index 185e9392259..0f2e0505d23 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java @@ -242,7 +242,7 @@ public abstract class ExtendedEntityManagerCreator { * InvocationHandler for extended EntityManagers as defined in the JPA spec. */ @SuppressWarnings("serial") - private static class ExtendedEntityManagerInvocationHandler implements InvocationHandler, Serializable { + private static final class ExtendedEntityManagerInvocationHandler implements InvocationHandler, Serializable { private static final Log logger = LogFactory.getLog(ExtendedEntityManagerInvocationHandler.class); diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java index 006188c1700..d4f9c158ece 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java @@ -745,7 +745,7 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager * Holder for suspended resources. * Used internally by {@code doSuspend} and {@code doResume}. */ - private static class SuspendedResourcesHolder { + private static final class SuspendedResourcesHolder { private final EntityManagerHolder entityManagerHolder; diff --git a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java index 275f7d5e385..585c8d9834b 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java @@ -127,6 +127,9 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi private static final String CID = "cid:"; + private static final EntityResolver NO_OP_ENTITY_RESOLVER = + (publicId, systemId) -> new InputSource(new StringReader("")); + /** Logger available to subclasses. */ protected final Log logger = LogFactory.getLog(getClass()); @@ -1079,8 +1082,4 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi } } - - private static final EntityResolver NO_OP_ENTITY_RESOLVER = - (publicId, systemId) -> new InputSource(new StringReader("")); - } diff --git a/spring-oxm/src/main/java/org/springframework/oxm/support/MarshallingSource.java b/spring-oxm/src/main/java/org/springframework/oxm/support/MarshallingSource.java index b512f230954..7bd396f87fd 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/support/MarshallingSource.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/support/MarshallingSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -102,7 +102,7 @@ public class MarshallingSource extends SAXSource { } - private static class MarshallingXMLReader implements XMLReader { + private static final class MarshallingXMLReader implements XMLReader { private final Marshaller marshaller; diff --git a/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java b/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java index b264c51f8db..925417704ba 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java @@ -52,7 +52,7 @@ import org.springframework.web.util.UriComponentsBuilder; * @author Rossen Stoyanchev * @since 5.0 */ -public class MockServerHttpRequest extends AbstractServerHttpRequest { +public final class MockServerHttpRequest extends AbstractServerHttpRequest { private final HttpMethod httpMethod; diff --git a/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java b/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java index b2108b471f0..0fddd7bb521 100644 --- a/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java +++ b/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java @@ -357,7 +357,7 @@ public class SimpleNamingContext implements Context { } - private static class NameClassPairEnumeration extends AbstractNamingEnumeration { + private static final class NameClassPairEnumeration extends AbstractNamingEnumeration { private NameClassPairEnumeration(SimpleNamingContext context, String root) throws NamingException { super(context, root); @@ -370,7 +370,7 @@ public class SimpleNamingContext implements Context { } - private static class BindingEnumeration extends AbstractNamingEnumeration { + private static final class BindingEnumeration extends AbstractNamingEnumeration { private BindingEnumeration(SimpleNamingContext context, String root) throws NamingException { super(context, root); diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockFilterChain.java b/spring-test/src/main/java/org/springframework/mock/web/MockFilterChain.java index 8bc520fe7db..ac6d5f107b7 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockFilterChain.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockFilterChain.java @@ -150,7 +150,7 @@ public class MockFilterChain implements FilterChain { /** * A filter that simply delegates to a Servlet. */ - private static class ServletFilterProxy implements Filter { + private static final class ServletFilterProxy implements Filter { private final Servlet delegateServlet; diff --git a/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java b/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java index c4074e7bd93..74a8aed2b71 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java @@ -63,7 +63,7 @@ import org.springframework.web.util.UriComponentsBuilder; * @author Arjen Poutsma * @since 5.0 */ -public class MockServerRequest implements ServerRequest { +public final class MockServerRequest implements ServerRequest { private final HttpMethod method; diff --git a/spring-test/src/main/java/org/springframework/test/annotation/SystemProfileValueSource.java b/spring-test/src/main/java/org/springframework/test/annotation/SystemProfileValueSource.java index 5a39918a770..0cd9aa992e6 100644 --- a/spring-test/src/main/java/org/springframework/test/annotation/SystemProfileValueSource.java +++ b/spring-test/src/main/java/org/springframework/test/annotation/SystemProfileValueSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import org.springframework.util.Assert; * @author Sam Brannen * @since 2.0 */ -public class SystemProfileValueSource implements ProfileValueSource { +public final class SystemProfileValueSource implements ProfileValueSource { private static final SystemProfileValueSource INSTANCE = new SystemProfileValueSource(); diff --git a/spring-test/src/main/java/org/springframework/test/annotation/TestAnnotationUtils.java b/spring-test/src/main/java/org/springframework/test/annotation/TestAnnotationUtils.java index a2b33faa513..21e7361802b 100644 --- a/spring-test/src/main/java/org/springframework/test/annotation/TestAnnotationUtils.java +++ b/spring-test/src/main/java/org/springframework/test/annotation/TestAnnotationUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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,12 @@ import org.springframework.core.annotation.AnnotatedElementUtils; * @author Sam Brannen * @since 4.2 */ -public class TestAnnotationUtils { +public final class TestAnnotationUtils { + + + private TestAnnotationUtils() { + } + /** * Get the {@code timeout} configured via the {@link Timed @Timed} diff --git a/spring-test/src/main/java/org/springframework/test/context/transaction/TestTransaction.java b/spring-test/src/main/java/org/springframework/test/context/transaction/TestTransaction.java index d238ed800fe..19d736619fc 100644 --- a/spring-test/src/main/java/org/springframework/test/context/transaction/TestTransaction.java +++ b/spring-test/src/main/java/org/springframework/test/context/transaction/TestTransaction.java @@ -38,7 +38,12 @@ import org.springframework.util.Assert; * @since 4.1 * @see TransactionalTestExecutionListener */ -public class TestTransaction { +public final class TestTransaction { + + + private TestTransaction() { + } + /** * Determine whether a test-managed transaction is currently active. diff --git a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionContextHolder.java b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionContextHolder.java index 5ee7edf4a79..ebb582ec969 100644 --- a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionContextHolder.java +++ b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionContextHolder.java @@ -25,12 +25,16 @@ import org.springframework.lang.Nullable; * @author Sam Brannen * @since 4.1 */ -class TransactionContextHolder { +final class TransactionContextHolder { private static final ThreadLocal currentTransactionContext = new NamedInheritableThreadLocal<>("Test Transaction Context"); + private TransactionContextHolder() { + } + + static void setCurrentTransactionContext(TransactionContext transactionContext) { currentTransactionContext.set(transactionContext); } diff --git a/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java b/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java index 4efd94f2392..d836c30399f 100644 --- a/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java +++ b/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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,15 @@ import org.springframework.util.StringUtils; * @see org.springframework.jdbc.datasource.init.ResourceDatabasePopulator * @see org.springframework.jdbc.datasource.init.DatabasePopulatorUtils */ -public class JdbcTestUtils { +public final class JdbcTestUtils { private static final Log logger = LogFactory.getLog(JdbcTestUtils.class); + private JdbcTestUtils() { + } + + /** * Count the rows in the given table. * @param jdbcTemplate the JdbcTemplate with which to perform JDBC operations diff --git a/spring-test/src/main/java/org/springframework/test/web/client/ExpectedCount.java b/spring-test/src/main/java/org/springframework/test/web/client/ExpectedCount.java index c3a476654d1..70c409cfd8c 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/ExpectedCount.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/ExpectedCount.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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,7 +38,7 @@ import org.springframework.util.Assert; * @author Rossen Stoyanchev * @since 4.3 */ -public class ExpectedCount { +public final class ExpectedCount { private final int minCount; diff --git a/spring-test/src/main/java/org/springframework/test/web/client/MockRestServiceServer.java b/spring-test/src/main/java/org/springframework/test/web/client/MockRestServiceServer.java index 11c53f0659b..cff5d4d2a10 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/MockRestServiceServer.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/MockRestServiceServer.java @@ -64,7 +64,7 @@ import org.springframework.web.client.support.RestGatewaySupport; * @since 3.2 */ @SuppressWarnings("deprecation") -public class MockRestServiceServer { +public final class MockRestServiceServer { private final RequestExpectationManager expectationManager; diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/MockMvcBuilders.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/MockMvcBuilders.java index 69fbdb81f4f..9bd26766db8 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/MockMvcBuilders.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/MockMvcBuilders.java @@ -33,7 +33,12 @@ import org.springframework.web.context.WebApplicationContext; * @see #webAppContextSetup(WebApplicationContext) * @see #standaloneSetup(Object...) */ -public class MockMvcBuilders { +public final class MockMvcBuilders { + + + private MockMvcBuilders() { + } + /** * Build a {@link MockMvc} instance using the given, fully initialized diff --git a/spring-tx/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java b/spring-tx/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java index 98f8379b332..97d65087a42 100644 --- a/spring-tx/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java +++ b/spring-tx/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,9 +28,9 @@ package org.springframework.dao; @SuppressWarnings("serial") public class IncorrectResultSizeDataAccessException extends DataRetrievalFailureException { - private int expectedSize; + private final int expectedSize; - private int actualSize; + private final int actualSize; /** diff --git a/spring-tx/src/main/java/org/springframework/jca/cci/connection/SingleConnectionFactory.java b/spring-tx/src/main/java/org/springframework/jca/cci/connection/SingleConnectionFactory.java index a20694a0930..1db961bd34e 100644 --- a/spring-tx/src/main/java/org/springframework/jca/cci/connection/SingleConnectionFactory.java +++ b/spring-tx/src/main/java/org/springframework/jca/cci/connection/SingleConnectionFactory.java @@ -225,7 +225,7 @@ public class SingleConnectionFactory extends DelegatingConnectionFactory impleme /** * Invocation handler that suppresses close calls on CCI Connections. */ - private static class CloseSuppressingInvocationHandler implements InvocationHandler { + private static final class CloseSuppressingInvocationHandler implements InvocationHandler { private final Connection target; diff --git a/spring-tx/src/main/java/org/springframework/transaction/HeuristicCompletionException.java b/spring-tx/src/main/java/org/springframework/transaction/HeuristicCompletionException.java index 6ad54261f82..d0c25013beb 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/HeuristicCompletionException.java +++ b/spring-tx/src/main/java/org/springframework/transaction/HeuristicCompletionException.java @@ -65,7 +65,7 @@ public class HeuristicCompletionException extends TransactionException { /** * The outcome state of the transaction: have some or all resources been committed? */ - private int outcomeState = STATE_UNKNOWN; + private final int outcomeState; /** diff --git a/spring-tx/src/main/java/org/springframework/transaction/InvalidTimeoutException.java b/spring-tx/src/main/java/org/springframework/transaction/InvalidTimeoutException.java index bf6f4c39677..4ba82146f75 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/InvalidTimeoutException.java +++ b/spring-tx/src/main/java/org/springframework/transaction/InvalidTimeoutException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ package org.springframework.transaction; @SuppressWarnings("serial") public class InvalidTimeoutException extends TransactionUsageException { - private int timeout; + private final int timeout; /** diff --git a/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java b/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java index 632c911827c..7965b6254bf 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java +++ b/spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java @@ -1273,7 +1273,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran * Holder for suspended resources. * Used internally by {@code suspend} and {@code resume}. */ - protected static class SuspendedResourcesHolder { + protected static final class SuspendedResourcesHolder { @Nullable private final Object suspendedResources; diff --git a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java index 96f041cb1db..85470d33884 100644 --- a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java +++ b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java @@ -39,7 +39,7 @@ import static java.time.format.DateTimeFormatter.*; * @since 5.0 * @see RFC 2183 */ -public class ContentDisposition { +public final class ContentDisposition { @Nullable private final String type; diff --git a/spring-web/src/main/java/org/springframework/http/InvalidMediaTypeException.java b/spring-web/src/main/java/org/springframework/http/InvalidMediaTypeException.java index e62f2377fb0..1e1818d885e 100644 --- a/spring-web/src/main/java/org/springframework/http/InvalidMediaTypeException.java +++ b/spring-web/src/main/java/org/springframework/http/InvalidMediaTypeException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import org.springframework.util.InvalidMimeTypeException; @SuppressWarnings("serial") public class InvalidMediaTypeException extends IllegalArgumentException { - private String mediaType; + private final String mediaType; /** diff --git a/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java b/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java index 60a3c04d992..f06d0d8a231 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java +++ b/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java @@ -40,13 +40,17 @@ import org.springframework.util.StringUtils; * @author Arjen Poutsma * @since 5.0 */ -public class MediaTypeFactory { +public final class MediaTypeFactory { private static final String MIME_TYPES_FILE_NAME = "/org/springframework/http/mime.types"; private static final MultiValueMap fileExtensionToMediaTypes = parseMimeTypes(); + private MediaTypeFactory() { + } + + /** * Parse the {@code mime.types} file found in the resources. Format is: * diff --git a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurerFactory.java b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurerFactory.java index a9f1a1f4b68..2c5b97055b9 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurerFactory.java +++ b/spring-web/src/main/java/org/springframework/http/codec/CodecConfigurerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -36,7 +36,7 @@ import org.springframework.util.ClassUtils; * @see ClientCodecConfigurer#create() * @see ServerCodecConfigurer#create() */ -class CodecConfigurerFactory { +final class CodecConfigurerFactory { private static final String DEFAULT_CONFIGURERS_PATH = "CodecConfigurer.properties"; @@ -59,6 +59,10 @@ class CodecConfigurerFactory { } + private CodecConfigurerFactory() { + } + + @SuppressWarnings("unchecked") public static T create(Class ifc) { Class impl = defaultCodecConfigurers.get(ifc); diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java index 71b20be9a7d..2634152df17 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java @@ -32,7 +32,7 @@ import org.springframework.lang.Nullable; * @see ServerSentEventHttpMessageWriter * @see Server-Sent Events W3C recommendation */ -public class ServerSentEvent { +public final class ServerSentEvent { @Nullable private final String id; diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java index efabe0317b1..9f60c4c8d83 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java @@ -42,7 +42,7 @@ import org.springframework.util.Assert; * @author Arjen Poutsma * @since 5.0 */ -class Jackson2Tokenizer { +final class Jackson2Tokenizer { private final JsonParser parser; diff --git a/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java b/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java index 4cf47888fd7..9dff04e405e 100644 --- a/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java +++ b/spring-web/src/main/java/org/springframework/http/server/DefaultPathContainer.java @@ -36,7 +36,7 @@ import org.springframework.util.StringUtils; * @author Rossen Stoyanchev * @since 5.0 */ -class DefaultPathContainer implements PathContainer { +final class DefaultPathContainer implements PathContainer { private static final MultiValueMap EMPTY_MAP = new LinkedMultiValueMap<>(0); diff --git a/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java b/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java index ef2e3fc0e81..e459c304ab0 100644 --- a/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java +++ b/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,10 +37,10 @@ import org.springframework.util.StringUtils; @SuppressWarnings("serial") public class HttpRequestMethodNotSupportedException extends ServletException { - private String method; + private final String method; @Nullable - private String[] supportedMethods; + private final String[] supportedMethods; /** diff --git a/spring-web/src/main/java/org/springframework/web/HttpSessionRequiredException.java b/spring-web/src/main/java/org/springframework/web/HttpSessionRequiredException.java index e5a5119801a..d6bf5a4be41 100644 --- a/spring-web/src/main/java/org/springframework/web/HttpSessionRequiredException.java +++ b/spring-web/src/main/java/org/springframework/web/HttpSessionRequiredException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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,7 +30,7 @@ import org.springframework.lang.Nullable; public class HttpSessionRequiredException extends ServletException { @Nullable - private String expectedAttribute; + private final String expectedAttribute; /** @@ -39,6 +39,7 @@ public class HttpSessionRequiredException extends ServletException { */ public HttpSessionRequiredException(String msg) { super(msg); + this.expectedAttribute = null; } /** diff --git a/spring-web/src/main/java/org/springframework/web/filter/RelativeRedirectResponseWrapper.java b/spring-web/src/main/java/org/springframework/web/filter/RelativeRedirectResponseWrapper.java index a3f5e938f52..ff574542504 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/RelativeRedirectResponseWrapper.java +++ b/spring-web/src/main/java/org/springframework/web/filter/RelativeRedirectResponseWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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,7 +30,7 @@ import org.springframework.web.util.WebUtils; * @author Rossen Stoyanchev * @since 4.3.10 */ -class RelativeRedirectResponseWrapper extends HttpServletResponseWrapper { +final class RelativeRedirectResponseWrapper extends HttpServletResponseWrapper { private final HttpStatus redirectStatus; diff --git a/spring-web/src/main/java/org/springframework/web/method/HandlerTypePredicate.java b/spring-web/src/main/java/org/springframework/web/method/HandlerTypePredicate.java index b9aa0628cdf..cdc8ec26f6f 100644 --- a/spring-web/src/main/java/org/springframework/web/method/HandlerTypePredicate.java +++ b/spring-web/src/main/java/org/springframework/web/method/HandlerTypePredicate.java @@ -46,7 +46,7 @@ import org.springframework.util.StringUtils; * @author Rossen Stoyanchev * @since 5.1 */ -public class HandlerTypePredicate implements Predicate> { +public final class HandlerTypePredicate implements Predicate> { private final Set basePackages; diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractCookieValueMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractCookieValueMethodArgumentResolver.java index a0f1480ab38..eb3ae8fc789 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractCookieValueMethodArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractCookieValueMethodArgumentResolver.java @@ -71,7 +71,7 @@ public abstract class AbstractCookieValueMethodArgumentResolver extends Abstract } - private static class CookieValueNamedValueInfo extends NamedValueInfo { + private static final class CookieValueNamedValueInfo extends NamedValueInfo { private CookieValueNamedValueInfo(CookieValue annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolver.java index 92b44790d73..a618b12f846 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolver.java @@ -77,7 +77,7 @@ public class ExpressionValueMethodArgumentResolver extends AbstractNamedValueMet } - private static class ExpressionValueNamedValueInfo extends NamedValueInfo { + private static final class ExpressionValueNamedValueInfo extends NamedValueInfo { private ExpressionValueNamedValueInfo(Value annotation) { super("@Value", false, annotation.value()); diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolver.java index 51ce11fd232..a8a2cf636e9 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolver.java @@ -88,7 +88,7 @@ public class RequestHeaderMethodArgumentResolver extends AbstractNamedValueMetho } - private static class RequestHeaderNamedValueInfo extends NamedValueInfo { + private static final class RequestHeaderNamedValueInfo extends NamedValueInfo { private RequestHeaderNamedValueInfo(RequestHeader annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); diff --git a/spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java b/spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java index 86b7aaaf97b..11fc8bde8e9 100644 --- a/spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java @@ -62,7 +62,7 @@ import org.springframework.web.server.session.WebSessionManager; * @since 5.0 * @see HttpWebHandlerAdapter */ -public class WebHttpHandlerBuilder { +public final class WebHttpHandlerBuilder { /** Well-known name for the target WebHandler in the bean factory. */ public static final String WEB_HANDLER_BEAN_NAME = "webHandler"; diff --git a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java index a0f4160cefd..49322aac801 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java @@ -53,6 +53,50 @@ final class HierarchicalUriComponents extends UriComponents { private static final String PATH_DELIMITER_STRING = "/"; + /** + * Represents an empty path. + */ + static final PathComponent NULL_PATH_COMPONENT = new PathComponent() { + + @Override + public String getPath() { + return ""; + } + + @Override + public List getPathSegments() { + return Collections.emptyList(); + } + + @Override + public PathComponent encode(Charset charset) { + return this; + } + + @Override + public void verify() { + } + + @Override + public PathComponent expand(UriTemplateVariables uriVariables) { + return this; + } + + @Override + public void copyToUriComponentsBuilder(UriComponentsBuilder builder) { + } + + @Override + public boolean equals(Object obj) { + return (this == obj); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } + }; + @Nullable private final String userInfo; @@ -862,43 +906,6 @@ final class HierarchicalUriComponents extends UriComponents { } - /** - * Represents an empty path. - */ - static final PathComponent NULL_PATH_COMPONENT = new PathComponent() { - @Override - public String getPath() { - return ""; - } - @Override - public List getPathSegments() { - return Collections.emptyList(); - } - @Override - public PathComponent encode(Charset charset) { - return this; - } - @Override - public void verify() { - } - @Override - public PathComponent expand(UriTemplateVariables uriVariables) { - return this; - } - @Override - public void copyToUriComponentsBuilder(UriComponentsBuilder builder) { - } - @Override - public boolean equals(Object obj) { - return (this == obj); - } - @Override - public int hashCode() { - return getClass().hashCode(); - } - }; - - private static class QueryUriTemplateVariables implements UriTemplateVariables { private final UriTemplateVariables delegate; diff --git a/spring-web/src/main/java/org/springframework/web/util/JavaScriptUtils.java b/spring-web/src/main/java/org/springframework/web/util/JavaScriptUtils.java index 3b6636a5ee1..c17b86493da 100644 --- a/spring-web/src/main/java/org/springframework/web/util/JavaScriptUtils.java +++ b/spring-web/src/main/java/org/springframework/web/util/JavaScriptUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,12 @@ package org.springframework.web.util; * @author Rossen Stoyanchev * @since 1.1.1 */ -public class JavaScriptUtils { +public final class JavaScriptUtils { + + + private JavaScriptUtils() { + } + /** * Turn JavaScript special characters into escaped characters. diff --git a/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java b/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java index 8751f27e9ad..97ec12d6989 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -170,7 +170,7 @@ public class UriTemplate implements Serializable { /** * Helper to extract variable names and regex for matching to actual URLs. */ - private static class TemplateInfo { + private static final class TemplateInfo { private final List variableNames; diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java index 1483b1ab064..78585a8b2ee 100644 --- a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java +++ b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java @@ -73,6 +73,25 @@ public class PathPattern implements Comparable { private static final PathContainer EMPTY_PATH = PathContainer.parsePath(""); + /** + * Comparator that sorts patterns by specificity as follows: + *

    + *
  1. Null instances are last. + *
  2. Catch-all patterns are last. + *
  3. If both patterns are catch-all, consider the length (longer wins). + *
  4. Compare wildcard and captured variable count (lower wins). + *
  5. Consider length (longer wins) + *
+ */ + public static final Comparator SPECIFICITY_COMPARATOR = + Comparator.nullsLast( + Comparator. + comparingInt(p -> p.isCatchAll() ? 1 : 0) + .thenComparingInt(p -> p.isCatchAll() ? scoreByNormalizedLength(p) : 0) + .thenComparingInt(PathPattern::getScore) + .thenComparingInt(PathPattern::scoreByNormalizedLength) + ); + /** The text of the parsed pattern. */ private final String patternString; @@ -408,6 +427,100 @@ public class PathPattern implements Comparable { return this.patternString; } + int getScore() { + return this.score; + } + + boolean isCatchAll() { + return this.catchAll; + } + + /** + * The normalized length is trying to measure the 'active' part of the pattern. It is computed + * by assuming all capture variables have a normalized length of 1. Effectively this means changing + * your variable name lengths isn't going to change the length of the active part of the pattern. + * Useful when comparing two patterns. + */ + int getNormalizedLength() { + return this.normalizedLength; + } + + char getSeparator() { + return this.separator; + } + + int getCapturedVariableCount() { + return this.capturedVariableCount; + } + + String toChainString() { + StringBuilder buf = new StringBuilder(); + PathElement pe = this.head; + while (pe != null) { + buf.append(pe.toString()).append(" "); + pe = pe.next; + } + return buf.toString().trim(); + } + + /** + * Return the string form of the pattern built from walking the path element chain. + * @return the string form of the pattern + */ + String computePatternString() { + StringBuilder buf = new StringBuilder(); + PathElement pe = this.head; + while (pe != null) { + buf.append(pe.getChars()); + pe = pe.next; + } + return buf.toString(); + } + + @Nullable + PathElement getHeadSection() { + return this.head; + } + + /** + * Join two paths together including a separator if necessary. + * Extraneous separators are removed (if the first path + * ends with one and the second path starts with one). + * @param path1 first path + * @param path2 second path + * @return joined path that may include separator if necessary + */ + private String concat(String path1, String path2) { + boolean path1EndsWithSeparator = (path1.charAt(path1.length() - 1) == this.separator); + boolean path2StartsWithSeparator = (path2.charAt(0) == this.separator); + if (path1EndsWithSeparator && path2StartsWithSeparator) { + return path1 + path2.substring(1); + } + else if (path1EndsWithSeparator || path2StartsWithSeparator) { + return path1 + path2; + } + else { + return path1 + this.separator + path2; + } + } + + /** + * Return if the container is not null and has more than zero elements. + * @param container a path container + * @return {@code true} has more than zero elements + */ + private boolean hasLength(@Nullable PathContainer container) { + return container != null && container.elements().size() > 0; + } + + private static int scoreByNormalizedLength(PathPattern pattern) { + return -pattern.getNormalizedLength(); + } + + private boolean pathContainerIsJustSeparator(PathContainer pathContainer) { + return pathContainer.value().length() == 1 && + pathContainer.value().charAt(0) == separator; + } /** * Holder for URI variables and path parameters (matrix variables) extracted @@ -455,6 +568,7 @@ public class PathPattern implements Comparable { } } + /** * Holder for the result of a match on the start of a pattern. * Provides access to the remaining path not matched to the pattern as well @@ -499,60 +613,6 @@ public class PathPattern implements Comparable { } } - int getScore() { - return this.score; - } - - boolean isCatchAll() { - return this.catchAll; - } - - /** - * The normalized length is trying to measure the 'active' part of the pattern. It is computed - * by assuming all capture variables have a normalized length of 1. Effectively this means changing - * your variable name lengths isn't going to change the length of the active part of the pattern. - * Useful when comparing two patterns. - */ - int getNormalizedLength() { - return this.normalizedLength; - } - - char getSeparator() { - return this.separator; - } - - int getCapturedVariableCount() { - return this.capturedVariableCount; - } - - String toChainString() { - StringBuilder buf = new StringBuilder(); - PathElement pe = this.head; - while (pe != null) { - buf.append(pe.toString()).append(" "); - pe = pe.next; - } - return buf.toString().trim(); - } - - /** - * Return the string form of the pattern built from walking the path element chain. - * @return the string form of the pattern - */ - String computePatternString() { - StringBuilder buf = new StringBuilder(); - PathElement pe = this.head; - while (pe != null) { - buf.append(pe.getChars()); - pe = pe.next; - } - return buf.toString(); - } - - @Nullable - PathElement getHeadSection() { - return this.head; - } /** * Encapsulates context when attempting a match. Includes some fixed state like the @@ -642,65 +702,4 @@ public class PathPattern implements Comparable { return ""; } } - - /** - * Join two paths together including a separator if necessary. - * Extraneous separators are removed (if the first path - * ends with one and the second path starts with one). - * @param path1 first path - * @param path2 second path - * @return joined path that may include separator if necessary - */ - private String concat(String path1, String path2) { - boolean path1EndsWithSeparator = (path1.charAt(path1.length() - 1) == this.separator); - boolean path2StartsWithSeparator = (path2.charAt(0) == this.separator); - if (path1EndsWithSeparator && path2StartsWithSeparator) { - return path1 + path2.substring(1); - } - else if (path1EndsWithSeparator || path2StartsWithSeparator) { - return path1 + path2; - } - else { - return path1 + this.separator + path2; - } - } - - /** - * Return if the container is not null and has more than zero elements. - * @param container a path container - * @return {@code true} has more than zero elements - */ - private boolean hasLength(@Nullable PathContainer container) { - return container != null && container.elements().size() > 0; - } - - - /** - * Comparator that sorts patterns by specificity as follows: - *
    - *
  1. Null instances are last. - *
  2. Catch-all patterns are last. - *
  3. If both patterns are catch-all, consider the length (longer wins). - *
  4. Compare wildcard and captured variable count (lower wins). - *
  5. Consider length (longer wins) - *
- */ - public static final Comparator SPECIFICITY_COMPARATOR = - Comparator.nullsLast( - Comparator. - comparingInt(p -> p.isCatchAll() ? 1 : 0) - .thenComparingInt(p -> p.isCatchAll() ? scoreByNormalizedLength(p) : 0) - .thenComparingInt(PathPattern::getScore) - .thenComparingInt(PathPattern::scoreByNormalizedLength) - ); - - private static int scoreByNormalizedLength(PathPattern pattern) { - return -pattern.getNormalizedLength(); - } - - private boolean pathContainerIsJustSeparator(PathContainer pathContainer) { - return pathContainer.value().length() == 1 && - pathContainer.value().charAt(0) == separator; - } - } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolver.java index 82b4aa8a75d..cae45ddf72f 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolver.java @@ -82,7 +82,7 @@ public class CookieValueMethodArgumentResolver extends AbstractNamedValueSyncArg } - private static class CookieValueNamedValueInfo extends NamedValueInfo { + private static final class CookieValueNamedValueInfo extends NamedValueInfo { private CookieValueNamedValueInfo(CookieValue annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolver.java index e5d12ea75eb..21ea837088f 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolver.java @@ -74,7 +74,7 @@ public class ExpressionValueMethodArgumentResolver extends AbstractNamedValueSyn } - private static class ExpressionValueNamedValueInfo extends NamedValueInfo { + private static final class ExpressionValueNamedValueInfo extends NamedValueInfo { private ExpressionValueNamedValueInfo(Value annotation) { super("@Value", false, annotation.value()); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMethodArgumentResolver.java index 0e999c84d3e..48248ae4459 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMethodArgumentResolver.java @@ -125,7 +125,7 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueSync } - private static class MatrixVariableNamedValueInfo extends NamedValueInfo { + private static final class MatrixVariableNamedValueInfo extends NamedValueInfo { private MatrixVariableNamedValueInfo(MatrixVariable annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolver.java index c783612d69a..4013cf6ba23 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolver.java @@ -95,7 +95,7 @@ public class RequestHeaderMethodArgumentResolver extends AbstractNamedValueSyncA } - private static class RequestHeaderNamedValueInfo extends NamedValueInfo { + private static final class RequestHeaderNamedValueInfo extends NamedValueInfo { private RequestHeaderNamedValueInfo(RequestHeader annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/ModelAndViewDefiningException.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/ModelAndViewDefiningException.java index 07bf3e0ff84..b97e64f1241 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/ModelAndViewDefiningException.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/ModelAndViewDefiningException.java @@ -35,7 +35,7 @@ import org.springframework.util.Assert; @SuppressWarnings("serial") public class ModelAndViewDefiningException extends ServletException { - private ModelAndView modelAndView; + private final ModelAndView modelAndView; /** diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMethodArgumentResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMethodArgumentResolver.java index a0bd0d29513..839193fa0da 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMethodArgumentResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,7 +127,7 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueMeth } - private static class MatrixVariableNamedValueInfo extends NamedValueInfo { + private static final class MatrixVariableNamedValueInfo extends NamedValueInfo { private MatrixVariableNamedValueInfo(MatrixVariable annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java index db10dfc489d..5681f606443 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java @@ -663,7 +663,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { context.registerComponent(new BeanComponentDefinition(beanDef, name)); } - private static class DecoratingFactoryBean implements FactoryBean { + private static final class DecoratingFactoryBean implements FactoryBean { private final WebSocketHandler handler; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java index cdf3683cae5..73611765e72 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,12 @@ import org.springframework.web.socket.sockjs.transport.handler.WebSocketTranspor * @author Rossen Stoyanchev * @since 4.0 */ -class WebSocketNamespaceUtils { +final class WebSocketNamespaceUtils { + + + private WebSocketNamespaceUtils() { + } + public static RuntimeBeanReference registerHandshakeHandler( Element element, ParserContext context, @Nullable Object source) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java index 3f4ae0bda78..942f858836a 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ public class WebSocketAnnotationMethodMessageHandler extends SimpAnnotationMetho /** * Adapt ControllerAdviceBean to MessagingAdviceBean. */ - private static class MessagingControllerAdviceBean implements MessagingAdviceBean { + private static final class MessagingControllerAdviceBean implements MessagingAdviceBean { private final ControllerAdviceBean adviceBean; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java index 82edf0a98d5..e13848e1a03 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java @@ -74,7 +74,6 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig private static final String XFRAME_OPTIONS_HEADER = "X-Frame-Options"; - protected final Log logger = LogFactory.getLog(getClass()); private final TaskScheduler taskScheduler; @@ -99,6 +98,10 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig protected final Set allowedOrigins = new LinkedHashSet<>(); + private final SockJsRequestHandler infoHandler = new InfoHandler(); + + private final SockJsRequestHandler iframeHandler = new IframeHandler(); + public AbstractSockJsService(TaskScheduler scheduler) { Assert.notNull(scheduler, "TaskScheduler must not be null"); @@ -539,7 +542,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig } - private final SockJsRequestHandler infoHandler = new SockJsRequestHandler() { + private class InfoHandler implements SockJsRequestHandler { private static final String INFO_CONTENT = "{\"entropy\":%s,\"origins\":[\"*:*\"],\"cookie_needed\":%s,\"websocket\":%s}"; @@ -569,7 +572,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig }; - private final SockJsRequestHandler iframeHandler = new SockJsRequestHandler() { + private class IframeHandler implements SockJsRequestHandler { private static final String IFRAME_CONTENT = "\n" +