diff --git a/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java b/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java index 5cb9a70a37e..0b87a6136d8 100644 --- a/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java +++ b/buildSrc/src/main/java/org/springframework/build/compile/CompilerConventionsPlugin.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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,6 +33,7 @@ import org.gradle.api.tasks.compile.JavaCompile; * with a dedicated property on the CLI: {@code "./gradlew test -PjavaSourceVersion=11"}. * * @author Brian Clozel + * @author Sam Brannen */ public class CompilerConventionsPlugin implements Plugin { @@ -40,13 +41,13 @@ public class CompilerConventionsPlugin implements Plugin { * The project property that can be used to switch the Java source * compatibility version for building source and test classes. */ - public static String JAVA_SOURCE_VERSION_PROPERTY = "javaSourceVersion"; + public static final String JAVA_SOURCE_VERSION_PROPERTY = "javaSourceVersion"; - public static JavaVersion DEFAULT_COMPILER_VERSION = JavaVersion.VERSION_1_8; + public static final JavaVersion DEFAULT_COMPILER_VERSION = JavaVersion.VERSION_1_8; - private static List COMPILER_ARGS; + private static final List COMPILER_ARGS; - private static List TEST_COMPILER_ARGS; + private static final List TEST_COMPILER_ARGS; static { List commonCompilerArgs = Arrays.asList( @@ -72,7 +73,8 @@ public class CompilerConventionsPlugin implements Plugin { } /** - * Applies the common Java compiler options for sources and test sources. + * Applies the common Java compiler options for main sources, test fixture sources, and + * test sources. * @param project the current project */ private void applyJavaCompileConventions(Project project) { @@ -93,10 +95,12 @@ public class CompilerConventionsPlugin implements Plugin { compileTask.getOptions().setEncoding("UTF-8"); }); project.getTasks().withType(JavaCompile.class) - .matching(javaCompile -> javaCompile.getName().equals(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME)) + .matching(javaCompile -> javaCompile.getName().equals(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME) + || javaCompile.getName().equals("compileTestFixturesJava")) .forEach(compileTask -> { compileTask.getOptions().setCompilerArgs(TEST_COMPILER_ARGS); compileTask.getOptions().setEncoding("UTF-8"); }); } -} \ No newline at end of file + +} diff --git a/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java index 6a703fe23a7..384973bd9aa 100644 --- a/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/advice/MethodCounter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -25,6 +25,7 @@ import java.util.HashMap; * * @author Rod Johnson * @author Chris Beams + * @author Sam Brannen */ @SuppressWarnings("serial") public class MethodCounter implements Serializable { @@ -39,15 +40,12 @@ public class MethodCounter implements Serializable { } protected void count(String methodName) { - Integer i = map.get(methodName); - i = (i != null) ? new Integer(i.intValue() + 1) : new Integer(1); - map.put(methodName, i); + map.merge(methodName, 1, (n, m) -> n + 1); ++allCount; } public int getCalls(String methodName) { - Integer i = map.get(methodName); - return (i != null ? i.intValue() : 0); + return map.getOrDefault(methodName, 0); } public int getCalls() { diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java index 10431c03425..ca3850a220a 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/TestBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -75,7 +75,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt private Date date = new Date(); - private Float myFloat = new Float(0.0); + private Float myFloat = Float.valueOf(0.0f); private Collection friends = new LinkedList<>();