diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java
index 70b928ab2fb..9e5136b152e 100644
--- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java
+++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.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.
@@ -123,15 +123,15 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
/**
* Find and return the first AspectJ annotation on the given method
- * (there should only be one anyway...)
+ * (there should only be one anyway...).
*/
@SuppressWarnings("unchecked")
@Nullable
protected static AspectJAnnotation> findAspectJAnnotationOnMethod(Method method) {
Class>[] classesToLookFor = new Class>[] {
Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
- for (Class> c : classesToLookFor) {
- AspectJAnnotation> foundAnnotation = findAnnotation(method, (Class) c);
+ for (Class> clazz : classesToLookFor) {
+ AspectJAnnotation> foundAnnotation = findAnnotation(method, (Class) clazz);
if (foundAnnotation != null) {
return foundAnnotation;
}
@@ -151,6 +151,9 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
}
+ /**
+ * AspectJ annotation types.
+ */
protected enum AspectJAnnotationType {
AtPointcut,
diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java
index f611eab5807..e2f8681e181 100644
--- a/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java
+++ b/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java
@@ -131,9 +131,14 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati
Collection annOps = provider.getCacheOperations(annotationParser);
if (annOps != null) {
if (ops == null) {
- ops = new ArrayList<>();
+ ops = annOps;
+ }
+ else {
+ Collection combined = new ArrayList<>(ops.size() + annOps.size());
+ combined.addAll(ops);
+ combined.addAll(annOps);
+ ops = combined;
}
- ops.addAll(annOps);
}
}
return ops;
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 4bf5532c79e..ba029f45ae2 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
@@ -155,7 +155,7 @@ public class AnnotationConfigUtils {
}
}
- Set beanDefs = new LinkedHashSet<>(4);
+ Set beanDefs = new LinkedHashSet<>(8);
if (!registry.containsBeanDefinition(CONFIGURATION_ANNOTATION_PROCESSOR_BEAN_NAME)) {
RootBeanDefinition def = new RootBeanDefinition(ConfigurationClassPostProcessor.class);
@@ -202,6 +202,7 @@ public class AnnotationConfigUtils {
def.setSource(source);
beanDefs.add(registerPostProcessor(registry, def, EVENT_LISTENER_PROCESSOR_BEAN_NAME));
}
+
if (!registry.containsBeanDefinition(EVENT_LISTENER_FACTORY_BEAN_NAME)) {
RootBeanDefinition def = new RootBeanDefinition(DefaultEventListenerFactory.class);
def.setSource(source);
diff --git a/spring-context/src/main/java/org/springframework/context/event/DefaultEventListenerFactory.java b/spring-context/src/main/java/org/springframework/context/event/DefaultEventListenerFactory.java
index 8d6cd686445..b0ffe7516a1 100644
--- a/spring-context/src/main/java/org/springframework/context/event/DefaultEventListenerFactory.java
+++ b/spring-context/src/main/java/org/springframework/context/event/DefaultEventListenerFactory.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.
@@ -24,6 +24,7 @@ import org.springframework.core.Ordered;
/**
* Default {@link EventListenerFactory} implementation that supports the
* regular {@link EventListener} annotation.
+ *
*
Used as "catch-all" implementation by default.
*
* @author Stephane Nicoll
@@ -33,15 +34,17 @@ public class DefaultEventListenerFactory implements EventListenerFactory, Ordere
private int order = LOWEST_PRECEDENCE;
- @Override
- public int getOrder() {
- return order;
- }
public void setOrder(int order) {
this.order = order;
}
+ @Override
+ public int getOrder() {
+ return this.order;
+ }
+
+
public boolean supportsMethod(Method method) {
return true;
}
diff --git a/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java b/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java
index d914df5ff41..8105d2465de 100644
--- a/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java
+++ b/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.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.
@@ -45,8 +45,7 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
/**
- * Register {@link EventListener} annotated method as individual {@link ApplicationListener}
- * instances.
+ * Registers {@link EventListener} methods as individual {@link ApplicationListener} instances.
*
* @author Stephane Nicoll
* @author Juergen Hoeller
diff --git a/spring-core/src/main/java/org/springframework/util/Base64Utils.java b/spring-core/src/main/java/org/springframework/util/Base64Utils.java
index 9806852017d..a127fc5fe3d 100644
--- a/spring-core/src/main/java/org/springframework/util/Base64Utils.java
+++ b/spring-core/src/main/java/org/springframework/util/Base64Utils.java
@@ -39,8 +39,6 @@ public abstract class Base64Utils {
* Base64-encode the given byte array.
* @param src the original byte array
* @return the encoded byte array
- * @throws IllegalStateException if Base64 encoding between byte arrays is not
- * supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtime
*/
public static byte[] encode(byte[] src) {
if (src.length == 0) {
@@ -53,8 +51,6 @@ public abstract class Base64Utils {
* Base64-decode the given byte array.
* @param src the encoded byte array
* @return the original byte array
- * @throws IllegalStateException if Base64 encoding between byte arrays is not
- * supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtime
*/
public static byte[] decode(byte[] src) {
if (src.length == 0) {
@@ -68,8 +64,6 @@ public abstract class Base64Utils {
* "URL and Filename Safe Alphabet".
* @param src the original byte array
* @return the encoded byte array
- * @throws IllegalStateException if Base64 encoding between byte arrays is not
- * supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtime
* @since 4.2.4
*/
public static byte[] encodeUrlSafe(byte[] src) {
@@ -84,8 +78,6 @@ public abstract class Base64Utils {
* "URL and Filename Safe Alphabet".
* @param src the encoded byte array
* @return the original byte array
- * @throws IllegalStateException if Base64 encoding between byte arrays is not
- * supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtime
* @since 4.2.4
*/
public static byte[] decodeUrlSafe(byte[] src) {
@@ -124,8 +116,6 @@ public abstract class Base64Utils {
* "URL and Filename Safe Alphabet".
* @param src the original byte array
* @return the encoded byte array as a UTF-8 String
- * @throws IllegalStateException if Base64 encoding between byte arrays is not
- * supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtime
*/
public static String encodeToUrlSafeString(byte[] src) {
return new String(encodeUrlSafe(src), DEFAULT_CHARSET);
@@ -136,8 +126,6 @@ public abstract class Base64Utils {
* "URL and Filename Safe Alphabet".
* @param src the encoded UTF-8 String
* @return the original byte array
- * @throws IllegalStateException if Base64 encoding between byte arrays is not
- * supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtime
*/
public static byte[] decodeFromUrlSafeString(String src) {
return decodeUrlSafe(src.getBytes(DEFAULT_CHARSET));
diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java
index b4d886ca174..c3e6fb1f0c4 100644
--- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java
+++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java
@@ -176,13 +176,15 @@ public class JdbcTemplateTests {
@Test
public void testStringsWithEmptyPreparedStatementArgs() throws Exception {
- doTestStrings(null, null, null, null, (template, sql, rch) -> template.query(sql, (Object[]) null, rch));
+ doTestStrings(null, null, null, null,
+ (template, sql, rch) -> template.query(sql, (Object[]) null, rch));
}
@Test
public void testStringsWithPreparedStatementArgs() throws Exception {
final Integer argument = 99;
- doTestStrings(null, null, null, argument, (template, sql, rch) -> template.query(sql, new Object[] { argument }, rch));
+ doTestStrings(null, null, null, argument,
+ (template, sql, rch) -> template.query(sql, new Object[] {argument}, rch));
}
private void doTestStrings(Integer fetchSize, Integer maxRows, Integer queryTimeout,
@@ -362,10 +364,10 @@ public class JdbcTemplateTests {
given(this.preparedStatement.executeUpdate()).willReturn(rowsAffected);
int actualRowsAffected = this.template.update(sql,
- new Object[] {4, new SqlParameterValue(Types.NUMERIC, 2, new Float(1.4142))});
+ 4, new SqlParameterValue(Types.NUMERIC, 2, Float.valueOf(1.4142f)));
assertTrue("Actual rows affected is correct", actualRowsAffected == rowsAffected);
verify(this.preparedStatement).setObject(1, 4);
- verify(this.preparedStatement).setObject(2, new Float(1.4142), Types.NUMERIC, 2);
+ verify(this.preparedStatement).setObject(2, Float.valueOf(1.4142f), Types.NUMERIC, 2);
verify(this.preparedStatement).close();
verify(this.connection).close();
}
@@ -427,8 +429,7 @@ public class JdbcTemplateTests {
public void testBatchUpdateWithBatchFailure() throws Exception {
final String[] sql = {"A", "B", "C", "D"};
given(this.statement.executeBatch()).willThrow(
- new BatchUpdateException(new int[] { 1, Statement.EXECUTE_FAILED, 1,
- Statement.EXECUTE_FAILED }));
+ new BatchUpdateException(new int[] {1, Statement.EXECUTE_FAILED, 1, Statement.EXECUTE_FAILED}));
mockDatabaseMetaData(true);
given(this.connection.createStatement()).willReturn(this.statement);
@@ -495,18 +496,16 @@ public class JdbcTemplateTests {
given(this.preparedStatement.executeBatch()).willReturn(rowsAffected);
mockDatabaseMetaData(true);
- BatchPreparedStatementSetter setter =
- new BatchPreparedStatementSetter() {
- @Override
- public void setValues(PreparedStatement ps, int i)
- throws SQLException {
- ps.setInt(1, ids[i]);
- }
- @Override
- public int getBatchSize() {
- return ids.length;
- }
- };
+ BatchPreparedStatementSetter setter = new BatchPreparedStatementSetter() {
+ @Override
+ public void setValues(PreparedStatement ps, int i) throws SQLException {
+ ps.setInt(1, ids[i]);
+ }
+ @Override
+ public int getBatchSize() {
+ return ids.length;
+ }
+ };
JdbcTemplate template = new JdbcTemplate(this.dataSource, false);
@@ -1049,10 +1048,9 @@ public class JdbcTemplateTests {
}
try {
- this.template.query(con -> con.prepareStatement("my query"),
- (ResultSetExtractor