Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f0efc64

Browse files
committed
Introduce ErrorProne, fix compiler warnings
Signed-off-by: Stefano Cordio <stefano.cordio@gmail.com>
1 parent 2bd5b84 commit f0efc64

File tree

105 files changed

+339
-291
lines changed

Some content is hidden

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

105 files changed

+339
-291
lines changed

‎.mvn/jvm.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
2+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
3+
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
4+
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
5+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
6+
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
7+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
8+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
9+
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
10+
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED

‎pom.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,34 @@
180180
<release>${java.version}</release>
181181
<compilerArgs>
182182
<compilerArg>-parameters</compilerArg>
183+
<!-- https://errorprone.info/docs/installation#maven -->
184+
<compilerArg>-XDcompilePolicy=simple</compilerArg>
185+
<compilerArg>--should-stop=ifError=FLOW</compilerArg>
186+
<compilerArg>
187+
-Xplugin:ErrorProne
188+
-Xep:DefaultCharset:OFF
189+
-Xep:EqualsGetClass:OFF
190+
-Xep:Finally:OFF
191+
-Xep:HidingField:OFF
192+
-Xep:JavaTimeDefaultTimeZone:OFF
193+
-Xep:JdkObsolete:OFF
194+
-Xep:MixedMutabilityReturnType:OFF
195+
-Xep:MutablePublicArray:OFF
196+
-Xep:NonAtomicVolatileUpdate:OFF
197+
-Xep:ReferenceEquality:OFF
198+
-Xep:StringCaseLocaleUsage:OFF
199+
-Xep:StringSplitter:OFF
200+
-Xep:SynchronizeOnNonFinalField:OFF
201+
</compilerArg>
183202
</compilerArgs>
203+
<failOnWarning>true</failOnWarning>
204+
<annotationProcessorPaths>
205+
<path>
206+
<groupId>com.google.errorprone</groupId>
207+
<artifactId>error_prone_core</artifactId>
208+
<version>2.37.0</version>
209+
</path>
210+
</annotationProcessorPaths>
184211
</configuration>
185212
</plugin>
186213
<plugin>

‎spring-batch-core/src/main/java/org/springframework/batch/core/Entity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public boolean equals(Object other) {
146146
@Override
147147
public int hashCode() {
148148
if (id == null) {
149-
return super.hashCode();
149+
return System.identityHashCode(this);
150150
}
151151
return 39 + 87 * id.hashCode();
152152
}

‎spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.io.IOException;
2020
import java.io.ObjectInputStream;
21+
import java.time.Clock;
2122
import java.time.LocalDateTime;
2223
import java.util.ArrayList;
2324
import java.util.Collection;
@@ -203,7 +204,7 @@ public void upgradeStatus(BatchStatus status) {
203204
/**
204205
* Convenience getter for the {@code id} of the enclosing job. Useful for DAO
205206
* implementations.
206-
* @return the @{code id} of the enclosing job.
207+
* @return the {@code id} of the enclosing job.
207208
*/
208209
public Long getJobId() {
209210
if (jobInstance != null) {

‎spring-batch-core/src/main/java/org/springframework/batch/core/JobParameters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public String toString() {
373373
for (Map.Entry<String, JobParameter<?>> entry : this.parameters.entrySet()) {
374374
parameters.add(String.format("'%s':'%s'", entry.getKey(), entry.getValue()));
375375
}
376-
return newStringBuilder("{").append(String.join(",", parameters)).append("}").toString();
376+
return "{" + String.join(",", parameters) + "}";
377377
}
378378

379379
}

‎spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ public boolean equals(Object obj) {
492492
return super.equals(obj);
493493
}
494494

495-
return stepName.equals(other.getStepName()) && (jobExecutionId.equals(other.getJobExecutionId()))
495+
return stepName.equals(other.getStepName()) && jobExecutionId.equals(other.getJobExecutionId())
496496
&& getId().equals(other.getId());
497497
}
498498

‎spring-batch-core/src/main/java/org/springframework/batch/core/configuration/JobFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface JobFactory {
3232
Job createJob();
3333

3434
/**
35-
* @return The {@link String} that contains the {@link Job} name.
35+
* Return the {@link String} that contains the {@link Job} name.
3636
*/
3737
String getJobName();
3838

‎spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/BatchObservabilityBeanPostProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw
5050
try {
5151
if (bean instanceof AbstractJob || bean instanceof AbstractStep) {
5252
ObservationRegistry observationRegistry = this.beanFactory.getBean(ObservationRegistry.class);
53-
if (bean instanceof AbstractJob) {
54-
((AbstractJob) bean).setObservationRegistry(observationRegistry);
53+
if (bean instanceof AbstractJobjob) {
54+
job.setObservationRegistry(observationRegistry);
5555
}
56-
if (bean instanceof AbstractStep) {
57-
((AbstractStep) bean).setObservationRegistry(observationRegistry);
56+
if (bean instanceof AbstractStepstep) {
57+
step.setObservationRegistry(observationRegistry);
5858
}
5959
}
6060
}

‎spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/BatchRegistrar.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ class BatchRegistrar implements ImportBeanDefinitionRegistrar {
4949

5050
private static final Log LOGGER = LogFactory.getLog(BatchRegistrar.class);
5151

52-
private static final String MISSING_ANNOTATION_ERROR_MESSAGE = "EnableBatchProcessing is not present on importing class '%s' as expected";
53-
5452
private static final String JOB_REPOSITORY = "jobRepository";
5553

5654
private static final String JOB_EXPLORER = "jobExplorer";
@@ -84,7 +82,8 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B
8482
private void validateState(AnnotationMetadata importingClassMetadata) {
8583
if (!importingClassMetadata.isAnnotated(EnableBatchProcessing.class.getName())) {
8684
String className = importingClassMetadata.getClassName();
87-
String errorMessage = String.format(MISSING_ANNOTATION_ERROR_MESSAGE, className);
85+
String errorMessage = "EnableBatchProcessing is not present on importing class '%s' as expected"
86+
.formatted(className);
8887
throw new IllegalStateException(errorMessage);
8988
}
9089
}

‎spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AbstractApplicationContextFactory.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.ArrayList;
2020
import java.util.Arrays;
2121
import java.util.Collection;
22+
import java.util.Collections;
2223
import java.util.List;
2324

2425
import org.apache.commons.logging.Log;
@@ -196,13 +197,11 @@ protected void prepareContext(ConfigurableApplicationContext parent, Configurabl
196197
protected void prepareBeanFactory(ConfigurableListableBeanFactory parent,
197198
ConfigurableListableBeanFactory beanFactory) {
198199
if (copyConfiguration && parent != null) {
199-
List<BeanPostProcessor> parentPostProcessors = new ArrayList<>();
200-
List<BeanPostProcessor> childPostProcessors = new ArrayList<>();
201-
202-
childPostProcessors.addAll(beanFactory instanceof AbstractBeanFactory
203-
? ((AbstractBeanFactory) beanFactory).getBeanPostProcessors() : new ArrayList<>());
204-
parentPostProcessors.addAll(parent instanceof AbstractBeanFactory
205-
? ((AbstractBeanFactory) parent).getBeanPostProcessors() : new ArrayList<>());
200+
List<BeanPostProcessor> childPostProcessors = new ArrayList<>(
201+
beanFactory instanceof AbstractBeanFactory factory ? factory.getBeanPostProcessors()
202+
: new ArrayList<>());
203+
List<BeanPostProcessor> parentPostProcessors = new ArrayList<>(parent instanceof AbstractBeanFactory factory
204+
? factory.getBeanPostProcessors() : new ArrayList<>());
206205

207206
try {
208207
Class<?> applicationContextAwareProcessorClass = ClassUtils.forName(
@@ -237,8 +236,8 @@ protected void prepareBeanFactory(ConfigurableListableBeanFactory parent,
237236

238237
beanFactory.copyConfigurationFrom(parent);
239238

240-
List<BeanPostProcessor> beanPostProcessors = beanFactory instanceof AbstractBeanFactory
241-
? ((AbstractBeanFactory) beanFactory).getBeanPostProcessors() : new ArrayList<>();
239+
List<BeanPostProcessor> beanPostProcessors = beanFactory instanceof AbstractBeanFactoryabstractBeanFactory
240+
? abstractBeanFactory.getBeanPostProcessors() : new ArrayList<>();
242241

243242
beanPostProcessors.clear();
244243
beanPostProcessors.addAll(aggregatedPostProcessors);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /