diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
index 2bc2f7f89b..279da65527 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.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.
@@ -1384,8 +1384,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
catch (ClassNotFoundException ex) {
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), ex);
}
- catch (LinkageError ex) {
- throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), ex);
+ catch (LinkageError err) {
+ throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), err);
}
}
diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java
index a8121d56b7..8a45734519 100644
--- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java
+++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java
@@ -22,7 +22,6 @@ import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.SmartInitializingSingleton;
-import org.springframework.cache.CacheManager;
/**
* Proxy factory bean for simplified declarative caching handling.
@@ -54,7 +53,7 @@ public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean
/**
- * Set the sources used to find cache operations.
+ * Set one or more sources to find cache operations.
* @see CacheInterceptor#setCacheOperationSources
*/
public void setCacheOperationSources(CacheOperationSource... cacheOperationSources) {
@@ -62,42 +61,9 @@ public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean
}
/**
- * Set the default {@link KeyGenerator} that this cache aspect should delegate to
- * if no specific key generator has been set for the operation.
- *
The default is a {@link SimpleKeyGenerator}.
- * @since 5.0.3
- * @see CacheInterceptor#setKeyGenerator
- */
- public void setKeyGenerator(KeyGenerator keyGenerator) {
- this.cacheInterceptor.setKeyGenerator(keyGenerator);
- }
-
- /**
- * Set the default {@link CacheResolver} that this cache aspect should delegate
- * to if no specific cache resolver has been set for the operation.
- *
The default resolver resolves the caches against their names and the
- * default cache manager.
- * @since 5.0.3
- * @see CacheInterceptor#setCacheResolver
- */
- public void setCacheResolver(CacheResolver cacheResolver) {
- this.cacheInterceptor.setCacheResolver(cacheResolver);
- }
-
- /**
- * Set the {@link CacheManager} to use to create a default {@link CacheResolver}.
- * Replace the current {@link CacheResolver}, if any.
- * @since 5.0.3
- * @see CacheInterceptor#setCacheManager
- */
- public void setCacheManager(CacheManager cacheManager) {
- this.cacheInterceptor.setCacheManager(cacheManager);
- }
-
- /**
- * Set a pointcut, i.e a bean that can cause conditional invocation
- * of the CacheInterceptor depending on method and attributes passed.
- * Note: Additional interceptors are always invoked.
+ * Set a pointcut, i.e. a bean that triggers conditional invocation of the
+ * {@link CacheInterceptor} depending on the method and attributes passed.
+ *
Note: Additional interceptors are always invoked.
* @see #setPreInterceptors
* @see #setPostInterceptors
*/
diff --git a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java
index 0d7090a081..acd14a5c0c 100644
--- a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java
+++ b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.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.
@@ -84,7 +84,8 @@ import org.springframework.util.StringUtils;
* @see ResourceBundleMessageSource
* @see java.util.ResourceBundle
*/
-public class ReloadableResourceBundleMessageSource extends AbstractResourceBasedMessageSource implements ResourceLoaderAware {
+public class ReloadableResourceBundleMessageSource extends AbstractResourceBasedMessageSource
+ implements ResourceLoaderAware {
private static final String PROPERTIES_SUFFIX = ".properties";
@@ -99,15 +100,15 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
private ResourceLoader resourceLoader = new DefaultResourceLoader();
- /** Cache to hold filename lists per Locale */
+ // Cache to hold filename lists per Locale
private final ConcurrentMap>> cachedFilenames =
new ConcurrentHashMap>>();
- /** Cache to hold already loaded properties per filename */
+ // Cache to hold already loaded properties per filename
private final ConcurrentMap cachedProperties =
new ConcurrentHashMap();
- /** Cache to hold merged loaded properties per locale */
+ // Cache to hold merged loaded properties per locale
private final ConcurrentMap cachedMergedProperties =
new ConcurrentHashMap();
diff --git a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java
index d7dce2b57c..48250948b0 100644
--- a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java
+++ b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.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.
@@ -387,9 +387,13 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou
}
@Override
- public boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime) {
+ public boolean needsReload(
+ String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime) {
+
if (super.needsReload(baseName, locale, format, loader, bundle, loadTime)) {
- cachedBundleMessageFormats.remove(bundle);
+ synchronized (cachedBundleMessageFormats) {
+ cachedBundleMessageFormats.remove(bundle);
+ }
return true;
}
else {
diff --git a/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java b/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java
index ae6384ebb4..0ea5e137b9 100644
--- a/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java
+++ b/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.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.
@@ -67,6 +67,7 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
setBeanClassLoader(beanClassLoader);
}
+
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
LoadTimeWeaver serverSpecificLoadTimeWeaver = createServerSpecificLoadTimeWeaver(classLoader);
@@ -84,8 +85,10 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
else {
try {
this.loadTimeWeaver = new ReflectiveLoadTimeWeaver(classLoader);
- logger.info("Using a reflective load-time weaver for class loader: " +
- this.loadTimeWeaver.getInstrumentableClassLoader().getClass().getName());
+ if (logger.isInfoEnabled()) {
+ logger.info("Using a reflective load-time weaver for class loader: " +
+ this.loadTimeWeaver.getInstrumentableClassLoader().getClass().getName());
+ }
}
catch (IllegalStateException ex) {
throw new IllegalStateException(ex.getMessage() + " Specify a custom LoadTimeWeaver or start your " +
@@ -106,24 +109,26 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
protected LoadTimeWeaver createServerSpecificLoadTimeWeaver(ClassLoader classLoader) {
String name = classLoader.getClass().getName();
try {
- if (name.startsWith("weblogic")) {
- return new WebLogicLoadTimeWeaver(classLoader);
+ if (name.startsWith("org.apache.catalina")) {
+ return new TomcatLoadTimeWeaver(classLoader);
}
else if (name.startsWith("org.glassfish")) {
return new GlassFishLoadTimeWeaver(classLoader);
}
- else if (name.startsWith("org.apache.catalina")) {
- return new TomcatLoadTimeWeaver(classLoader);
- }
else if (name.startsWith("org.jboss")) {
return new JBossLoadTimeWeaver(classLoader);
}
else if (name.startsWith("com.ibm")) {
return new WebSphereLoadTimeWeaver(classLoader);
}
+ else if (name.startsWith("weblogic")) {
+ return new WebLogicLoadTimeWeaver(classLoader);
+ }
}
- catch (IllegalStateException ex) {
- logger.info("Could not obtain server-specific LoadTimeWeaver: " + ex.getMessage());
+ catch (Exception ex) {
+ if (logger.isInfoEnabled()) {
+ logger.info("Could not obtain server-specific LoadTimeWeaver: " + ex.getMessage());
+ }
}
return null;
}
@@ -131,8 +136,10 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
@Override
public void destroy() {
if (this.loadTimeWeaver instanceof InstrumentationLoadTimeWeaver) {
- logger.info("Removing all registered transformers for class loader: " +
- this.loadTimeWeaver.getInstrumentableClassLoader().getClass().getName());
+ if (logger.isInfoEnabled()) {
+ logger.info("Removing all registered transformers for class loader: " +
+ this.loadTimeWeaver.getInstrumentableClassLoader().getClass().getName());
+ }
((InstrumentationLoadTimeWeaver) this.loadTimeWeaver).removeTransformers();
}
}
diff --git a/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java b/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java
index a2ebe34719..1dbe191697 100644
--- a/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java
+++ b/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.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.
@@ -23,6 +23,8 @@ import java.util.List;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
+import org.springframework.util.StringUtils;
+
/**
* {@link CommandLinePropertySource} implementation backed by a JOpt {@link OptionSet}.
*
@@ -84,13 +86,13 @@ public class JOptCommandLinePropertySource extends CommandLinePropertySource names = new ArrayList();
for (OptionSpec> spec : this.source.specs()) {
- List aliases = new ArrayList(spec.options());
+ List aliases = spec.options();
if (!aliases.isEmpty()) {
// Only the longest name is used for enumerating
names.add(aliases.get(aliases.size() - 1));
}
}
- return names.toArray(new String[names.size()]);
+ return StringUtils.toStringArray(names);
}
@Override
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 083a7d0455..c52f28d717 100644
--- a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java
+++ b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-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.
@@ -149,10 +149,8 @@ public class CodeFlow implements Opcodes {
* Return the descriptor for the item currently on top of the stack (in the current scope).
*/
public String lastDescriptor() {
- if (this.compilationScopes.peek().isEmpty()) {
- return null;
- }
- return this.compilationScopes.peek().get(this.compilationScopes.peek().size() - 1);
+ ArrayList scopes = this.compilationScopes.peek();
+ return (!scopes.isEmpty() ? scopes.get(scopes.size() - 1) : null);
}
/**
@@ -161,7 +159,7 @@ public class CodeFlow implements Opcodes {
* @param mv the visitor into which new instructions should be inserted
*/
public void unboxBooleanIfNecessary(MethodVisitor mv) {
- if (lastDescriptor().equals("Ljava/lang/Boolean")) {
+ if ("Ljava/lang/Boolean".equals(lastDescriptor())) {
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z", false);
}
}
diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java
index fe13f03b1a..8c8db17c56 100644
--- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java
+++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java
@@ -70,9 +70,8 @@ public class FunctionReference extends SpelNodeImpl {
if (value == TypedValue.NULL) {
throw new SpelEvaluationException(getStartPosition(), SpelMessage.FUNCTION_NOT_DEFINED, this.name);
}
-
- // Two possibilities: a lambda function or a Java static method registered as a function
if (!(value.getValue() instanceof Method)) {
+ // Two possibilities: a lambda function or a Java static method registered as a function
throw new SpelEvaluationException(
SpelMessage.FUNCTION_REFERENCE_CANNOT_BE_INVOKED, this.name, value.getClass());
}
@@ -96,11 +95,13 @@ public class FunctionReference extends SpelNodeImpl {
private TypedValue executeFunctionJLRMethod(ExpressionState state, Method method) throws EvaluationException {
Object[] functionArgs = getArguments(state);
- if (!method.isVarArgs() && method.getParameterCount() != functionArgs.length) {
- throw new SpelEvaluationException(SpelMessage.INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION,
- functionArgs.length, method.getParameterCount());
+ if (!method.isVarArgs()) {
+ int declaredParamCount = method.getParameterTypes().length;
+ if (declaredParamCount != functionArgs.length) {
+ throw new SpelEvaluationException(SpelMessage.INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION,
+ functionArgs.length, declaredParamCount);
+ }
}
- // Only static methods can be called in this way
if (!Modifier.isStatic(method.getModifiers())) {
throw new SpelEvaluationException(getStartPosition(),
SpelMessage.FUNCTION_MUST_BE_STATIC, ClassUtils.getQualifiedMethodName(method), this.name);
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java
index a30c9186a0..ab96ef62ce 100755
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java
+++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.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.
@@ -51,43 +51,43 @@ import org.springframework.util.StringUtils;
*/
public class CallMetaDataContext {
- /** Logger available to subclasses */
+ // Logger available to subclasses
protected final Log logger = LogFactory.getLog(getClass());
- /** name of procedure to call **/
+ // Name of procedure to call
private String procedureName;
- /** name of catalog for call **/
+ // Name of catalog for call
private String catalogName;
- /** name of schema for call **/
+ // Name of schema for call
private String schemaName;
- /** List of SqlParameter objects to be used in call execution */
+ // List of SqlParameter objects to be used in call execution
private List callParameters = new ArrayList();
- /** Actual name to use for the return value in the output map */
+ // Actual name to use for the return value in the output map
private String actualFunctionReturnName;
- /** Set of in parameter names to exclude use for any not listed */
+ // Set of in parameter names to exclude use for any not listed
private Set limitedInParameterNames = new HashSet();
- /** List of SqlParameter names for out parameters */
+ // List of SqlParameter names for out parameters
private List outParameterNames = new ArrayList();
- /** Indicates whether this is a procedure or a function **/
+ // Indicates whether this is a procedure or a function
private boolean function = false;
- /** Indicates whether this procedure's return value should be included **/
+ // Indicates whether this procedure's return value should be included
private boolean returnValueRequired = false;
- /** Should we access call parameter meta data info or not */
+ // Should we access call parameter meta data info or not
private boolean accessCallParameterMetaData = true;
- /** Should we bind parameter by name **/
+ // Should we bind parameter by name
private boolean namedBinding;
- /** The provider of call meta data */
+ // The provider of call meta data
private CallMetaDataProvider metaDataProvider;
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java
index 818f525ba7..4e62e98eff 100644
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java
+++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-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,34 +44,34 @@ import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;
*/
public class TableMetaDataContext {
- /** Logger available to subclasses */
+ // Logger available to subclasses
protected final Log logger = LogFactory.getLog(getClass());
- /** Name of table for this context */
+ // Name of table for this context
private String tableName;
- /** Name of catalog for this context */
+ // Name of catalog for this context
private String catalogName;
- /** Name of schema for this context */
+ // Name of schema for this context
private String schemaName;
- /** List of columns objects to be used in this context */
+ // List of columns objects to be used in this context
private List tableColumns = new ArrayList();
- /** should we access insert parameter meta data info or not */
+ // Should we access insert parameter meta data info or not
private boolean accessTableColumnMetaData = true;
- /** should we override default for including synonyms for meta data lookups */
+ // Should we override default for including synonyms for meta data lookups
private boolean overrideIncludeSynonymsDefault = false;
- /** the provider of table meta data */
+ // The provider of table meta data
private TableMetaDataProvider metaDataProvider;
- /** are we using generated key columns */
+ // Are we using generated key columns
private boolean generatedKeyColumnsUsed = false;
- /** NativeJdbcExtractor to be used to retrieve the native connection */
+ // NativeJdbcExtractor to be used to retrieve the native connection
NativeJdbcExtractor nativeJdbcExtractor;
@@ -204,8 +204,8 @@ public class TableMetaDataContext {
*/
public List