Skip to content

Commit 2567b20

Browse files
committed
Upgrade to spring-javaformat 0.0.28 and downgrade to Checkstyle 8.41
In order to be able to use text blocks and other new Java language features, we are upgrading to a recent version of Checkstyle. The latest version of spring-javaformat-checkstyle (0.0.28) is built against Checkstyle 8.32 which does not include support for language features such as text blocks. Support for text blocks was added in Checkstyle 8.36. In addition, there is a binary compatibility issue between spring-javaformat-checkstyle 0.0.28 and Checkstyle 8.42. Thus we cannot use Checkstyle 8.42 or higher. In this commit, we therefore upgrade to spring-javaformat-checkstyle 0.0.28 and downgrade to Checkstyle 8.41. This change is being applied to `5.3.x` as well as `main` in order to benefit from the enhanced checking provided in more recent versions of Checkstyle. Closes gh-27481
1 parent 119c78b commit 2567b20

File tree

173 files changed

+221
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+221
-138
lines changed

build.gradle

+3-2
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ configure([rootProject] + javaProjects) { project ->
340340
}
341341

342342
checkstyle {
343-
toolVersion = "8.45.1"
343+
toolVersion = "8.41"
344344
configDirectory.set(rootProject.file("src/checkstyle"))
345345
}
346346

@@ -362,7 +362,8 @@ configure([rootProject] + javaProjects) { project ->
362362
// JSR-305 only used for non-required meta-annotations
363363
compileOnly("com.google.code.findbugs:jsr305")
364364
testCompileOnly("com.google.code.findbugs:jsr305")
365-
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.15")
365+
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.28")
366+
checkstyle("com.puppycrawl.tools:checkstyle:8.41")
366367
}
367368

368369
ext.javadocLinks = [

spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -146,7 +146,7 @@ public int hashCode() {
146146

147147
@Override
148148
public String toString() {
149-
return getClass().getName() + ": class = " + this.clazz.getName() + "; methodName = " + methodName;
149+
return getClass().getName() + ": class = " + this.clazz.getName() + "; methodName = " + this.methodName;
150150
}
151151

152152
}

spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.aop.support;
1718

1819
import org.junit.jupiter.api.Test;
@@ -29,10 +30,10 @@
2930
* @author Rob Harrop
3031
* @author Rick Evans
3132
*/
32-
public class ClassUtilsTests {
33+
class ClassUtilsTests {
3334

3435
@Test
35-
public void getShortNameForCglibClass() {
36+
void getShortNameForCglibClass() {
3637
TestBean tb = new TestBean();
3738
ProxyFactory pf = new ProxyFactory();
3839
pf.setTarget(tb);
@@ -41,4 +42,5 @@ public void getShortNameForCglibClass() {
4142
String className = ClassUtils.getShortName(proxy.getClass());
4243
assertThat(className).as("Class name did not match").isEqualTo("TestBean");
4344
}
45+
4446
}

spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/ConfigurableObject.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,14 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.beans.factory.aspectj;
1718

1819
/**
19-
* Marker interface for domain object that need DI through aspects.
20+
* Marker interface for domain objects that need DI through aspects.
2021
*
2122
* @author Ramnivas Laddad
2223
* @since 2.5
2324
*/
2425
public interface ConfigurableObject {
25-
2626
}

spring-aspects/src/test/java/org/springframework/transaction/aspectj/ClassWithPrivateAnnotatedMember.java

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.transaction.aspectj;
1718

1819
import org.springframework.transaction.annotation.Transactional;
@@ -29,4 +30,5 @@ public void doSomething() {
2930

3031
@Transactional
3132
private void doInTransaction() {}
33+
3234
}

spring-aspects/src/test/java/org/springframework/transaction/aspectj/ClassWithProtectedAnnotatedMember.java

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.transaction.aspectj;
1718

1819
import org.springframework.transaction.annotation.Transactional;
@@ -29,4 +30,5 @@ public void doSomething() {
2930

3031
@Transactional
3132
protected void doInTransaction() {}
33+
3234
}

spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/CustomCallbackBean.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.beans.factory.support.security.support;
1718

1819
/**
@@ -27,4 +28,5 @@ public void init() {
2728
public void destroy() {
2829
System.setProperty("security.destroy", "true");
2930
}
31+
3032
}

spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/DestroyBean.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.beans.factory.support.security.support;
1718

1819
import org.springframework.beans.factory.DisposableBean;
@@ -26,4 +27,5 @@ public class DestroyBean implements DisposableBean {
2627
public void destroy() throws Exception {
2728
System.setProperty("security.destroy", "true");
2829
}
30+
2931
}

spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/FactoryBean.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.beans.factory.support.security.support;
1718

1819
/**
@@ -33,4 +34,5 @@ public Object makeInstance() {
3334
System.getProperties();
3435
return new Object();
3536
}
37+
3638
}

spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/InitBean.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.beans.factory.support.security.support;
1718

1819
import org.springframework.beans.factory.InitializingBean;
@@ -26,4 +27,5 @@ public class InitBean implements InitializingBean {
2627
public void afterPropertiesSet() throws Exception {
2728
System.getProperties();
2829
}
30+
2931
}

spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/PropertyBean.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.beans.factory.support.security.support;
1718

1819
/**
@@ -27,4 +28,5 @@ public void setSecurityProperty(Object property) {
2728
public void setProperty(Object property) {
2829

2930
}
31+
3032
}

spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/DummyBean.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.beans.testfixture.beans;
1718

1819
/**
@@ -65,4 +66,5 @@ public int getAge() {
6566
public TestBean getSpouse() {
6667
return spouse;
6768
}
69+
6870
}

spring-context/src/main/java/org/springframework/format/FormatterRegistrar.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.format;
1718

1819
import org.springframework.core.convert.converter.Converter;

spring-context/src/main/java/org/springframework/scheduling/support/CronExpression.java

-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ private CronExpression(
171171
* <li>{@code "@daily"} (or {@code "@midnight"}) to run once a day, i.e. {@code "0 0 0 * * *"},</li>
172172
* <li>{@code "@hourly"} to run once an hour, i.e. {@code "0 0 * * * *"}.</li>
173173
* </ul>
174-
*
175174
* @param expression the expression string to parse
176175
* @return the parsed {@code CronExpression} object
177176
* @throws IllegalArgumentException in the expression does not conform to

spring-context/src/test/java/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.aop.aspectj;
1718

1819
import org.aspectj.lang.ProceedingJoinPoint;

spring-context/src/test/java/org/springframework/context/annotation/InvalidConfigurationClassDefinitionTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.context.annotation;
1718

1819
import org.junit.jupiter.api.Test;

spring-core/src/jmh/java/org/springframework/core/codec/StringDecoderBenchmark.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.core.codec;
1718

1819
import java.nio.charset.Charset;

spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ private ClassLoader getClassLoader() {
573573
}
574574
if (this.source != null) {
575575
if (this.source instanceof Class) {
576-
return ((Class<?>) source).getClassLoader();
576+
return ((Class<?>) this.source).getClassLoader();
577577
}
578578
if (this.source instanceof Member) {
579579
((Member) this.source).getDeclaringClass().getClassLoader();

spring-core/src/main/java/org/springframework/core/codec/DecodingException.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.core.codec;
1718

1819
import org.springframework.lang.Nullable;

spring-core/src/main/java/org/springframework/core/codec/EncodingException.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.core.codec;
1718

1819
import org.springframework.lang.Nullable;

spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ protected AbstractEnvironment(MutablePropertySources propertySources) {
138138
customizePropertySources(propertySources);
139139
}
140140

141-
142141
/**
143142
* Factory method used to create the {@link ConfigurablePropertyResolver}
144143
* instance used by the Environment.
@@ -168,6 +167,7 @@ protected final ConfigurablePropertyResolver getPropertyResolver() {
168167
* sources using {@link MutablePropertySources#addLast(PropertySource)} such that
169168
* further subclasses may call {@code super.customizePropertySources()} with
170169
* predictable results. For example:
170+
*
171171
* <pre class="code">
172172
* public class Level1Environment extends AbstractEnvironment {
173173
* &#064;Override
@@ -187,11 +187,13 @@ protected final ConfigurablePropertyResolver getPropertyResolver() {
187187
* }
188188
* }
189189
* </pre>
190-
* In this arrangement, properties will be resolved against sources A, B, C, D in that
190+
*
191+
* <p>In this arrangement, properties will be resolved against sources A, B, C, D in that
191192
* order. That is to say that property source "A" has precedence over property source
192193
* "D". If the {@code Level2Environment} subclass wished to give property sources C
193194
* and D higher precedence than A and B, it could simply call
194195
* {@code super.customizePropertySources} after, rather than before adding its own:
196+
*
195197
* <pre class="code">
196198
* public class Level2Environment extends Level1Environment {
197199
* &#064;Override
@@ -202,25 +204,24 @@ protected final ConfigurablePropertyResolver getPropertyResolver() {
202204
* }
203205
* }
204206
* </pre>
205-
* The search order is now C, D, A, B as desired.
206207
*
207-
* <p>Beyond these recommendations, subclasses may use any of the {@code add&#42;},
208+
* <p>The search order is now C, D, A, B as desired.
209+
* <p>Beyond these recommendations, subclasses may use any of the {@code add*},
208210
* {@code remove}, or {@code replace} methods exposed by {@link MutablePropertySources}
209211
* in order to create the exact arrangement of property sources desired.
210-
*
211212
* <p>The base implementation registers no property sources.
212-
*
213213
* <p>Note that clients of any {@link ConfigurableEnvironment} may further customize
214214
* property sources via the {@link #getPropertySources()} accessor, typically within
215215
* an {@link org.springframework.context.ApplicationContextInitializer
216216
* ApplicationContextInitializer}. For example:
217+
*
217218
* <pre class="code">
218219
* ConfigurableEnvironment env = new StandardEnvironment();
219220
* env.getPropertySources().addLast(new PropertySourceX(...));
220221
* </pre>
221222
*
222223
* <h2>A warning about instance variable access</h2>
223-
* Instance variables declared in subclasses and having default initial values should
224+
* <p>Instance variables declared in subclasses and having default initial values should
224225
* <em>not</em> be accessed from within this method. Due to Java object creation
225226
* lifecycle constraints, any initial value will not yet be assigned when this
226227
* callback is invoked by the {@link #AbstractEnvironment()} constructor, which may
@@ -229,7 +230,6 @@ protected final ConfigurablePropertyResolver getPropertyResolver() {
229230
* property source manipulation and instance variable access directly within the
230231
* subclass constructor. Note that <em>assigning</em> values to instance variables is
231232
* not problematic; it is only attempting to read default values that must be avoided.
232-
*
233233
* @see MutablePropertySources
234234
* @see PropertySourcesPropertyResolver
235235
* @see org.springframework.context.ApplicationContextInitializer

0 commit comments

Comments
 (0)