Skip to content

Commit 614a542

Browse files
committed
Don't call wrapper constructors directly
The constructors of the wrapper classes for primitives (Double, Integer, Long) have been deprecated since JDK 9 and should no longer be called. Instead the static factory #valueOf should be used.
1 parent f2c1296 commit 614a542

File tree

31 files changed

+90
-90
lines changed

31 files changed

+90
-90
lines changed

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/football/FootballJobIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2019 the original author or authors.
2+
* Copyright 2006-2020 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.
@@ -67,7 +67,7 @@ public void testLaunchJob() throws Exception {
6767
logger.info("Processed: " + stepExecution);
6868
if (stepExecution.getStepName().equals("playerload")) {
6969
// The effect of the retries
70-
assertEquals(new Double(Math.ceil(stepExecution.getReadCount() / 10. + 1)).intValue(),
70+
assertEquals((int) Math.ceil(stepExecution.getReadCount() / 10. + 1),
7171
stepExecution.getCommitCount());
7272
}
7373
}

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/SplitJobMapRepositoryIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2019 the original author or authors.
2+
* Copyright 2006-2020 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.
@@ -69,7 +69,7 @@ public void testMultithreadedSplit() throws Throwable {
6969
}
7070

7171
try {
72-
JobExecution execution = jobLauncher.run(job, new JobParametersBuilder().addLong("count", new Long(i))
72+
JobExecution execution = jobLauncher.run(job, new JobParametersBuilder().addLong("count", (long) i)
7373
.toJobParameters());
7474
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
7575
}

spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/CommandLineJobRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ private List<JobExecution> getRunningJobExecutions(String jobIdentifier) {
475475

476476
private Long getLongIdentifier(String jobIdentifier) {
477477
try {
478-
return new Long(jobIdentifier);
478+
return Long.parseLong(jobIdentifier);
479479
}
480480
catch (NumberFormatException e) {
481481
// Not an ID - must be a name

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2019 the original author or authors.
2+
* Copyright 2006-2020 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.
@@ -348,7 +348,7 @@ private void insertParameter(Long executionId, ParameterType type, String key,
348348
0L, 0D, identifyingFlag};
349349
} else if (type == ParameterType.LONG) {
350350
args = new Object[] { executionId, key, type, "", new Timestamp(0L),
351-
value, new Double(0), identifyingFlag};
351+
value, 0.0d, identifyingFlag};
352352
} else if (type == ParameterType.DOUBLE) {
353353
args = new Object[] { executionId, key, type, "", new Timestamp(0L), 0L,
354354
value, identifyingFlag};

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public int compareTo(ContextKey them) {
6565
if(them == null) {
6666
return 1;
6767
}
68-
final int idCompare = new Long(this.id).compareTo(new Long(them.id)); // JDK6 Make this Long.compare(x,y)
68+
final int idCompare = Long.compare(this.id, them.id);
6969
if(idCompare != 0) {
7070
return idCompare;
7171
}

spring-batch-core/src/test/java/org/springframework/batch/core/EntityTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2007 the original author or authors.
2+
* Copyright 2006-2020 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.
@@ -23,7 +23,7 @@
2323
*/
2424
public class EntityTests extends TestCase {
2525

26-
Entity entity = new Entity(new Long(11));
26+
Entity entity = new Entity(11L);
2727

2828
/**
2929
* Test method for {@link org.springframework.batch.core.Entity#hashCode()}.
@@ -54,7 +54,7 @@ public void testGetVersion() {
5454
*/
5555
public void testIncrementVersion() {
5656
entity.incrementVersion();
57-
assertEquals(new Integer(0), entity.getVersion());
57+
assertEquals(Integer.valueOf(0), entity.getVersion());
5858
}
5959

6060
/**
@@ -63,7 +63,7 @@ public void testIncrementVersion() {
6363
public void testIncrementVersionTwice() {
6464
entity.incrementVersion();
6565
entity.incrementVersion();
66-
assertEquals(new Integer(1), entity.getVersion());
66+
assertEquals(Integer.valueOf(1), entity.getVersion());
6767
}
6868

6969
/**

spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2018 the original author or authors.
2+
* Copyright 2006-2020 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.
@@ -35,8 +35,8 @@
3535
*/
3636
public class JobExecutionTests {
3737

38-
private JobExecution execution = new JobExecution(new JobInstance(new Long(11), "foo"),
39-
new Long(12), new JobParameters(), null);
38+
private JobExecution execution = new JobExecution(new JobInstance(11L, "foo"),
39+
12L, new JobParameters(), null);
4040

4141
@Test
4242
public void testJobExecution() {
@@ -135,7 +135,7 @@ public void testDowngradeStatus() {
135135
@Test
136136
public void testGetJobId() {
137137
assertEquals(11, execution.getJobId().longValue());
138-
execution = new JobExecution(new JobInstance(new Long(23), "testJob"), null, new JobParameters(), null);
138+
execution = new JobExecution(new JobInstance(23L, "testJob"), null, new JobParameters(), null);
139139
assertEquals(23, execution.getJobId().longValue());
140140
}
141141

spring-batch-core/src/test/java/org/springframework/batch/core/JobInstanceTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2014 the original author or authors.
2+
* Copyright 2006-2020 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.
@@ -27,15 +27,15 @@
2727
*/
2828
public class JobInstanceTests {
2929

30-
private JobInstance instance = new JobInstance(new Long(11), "job");
30+
private JobInstance instance = new JobInstance(11L, "job");
3131

3232
/**
3333
* Test method for
3434
* {@link org.springframework.batch.core.JobInstance#getJobName()}.
3535
*/
3636
@Test
3737
public void testGetName() {
38-
instance = new JobInstance(new Long(1), "foo");
38+
instance = new JobInstance(1L, "foo");
3939
assertEquals("foo", instance.getJobName());
4040
}
4141

@@ -59,7 +59,7 @@ public void testCreateWithNulls() {
5959

6060
@Test
6161
public void testSerialization() {
62-
instance = new JobInstance(new Long(1), "jobName");
62+
instance = new JobInstance(1L, "jobName");
6363

6464
byte[] serialized = SerializationUtils.serialize(instance);
6565

spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2018 the original author or authors.
2+
* Copyright 2008-2020 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.
@@ -96,9 +96,9 @@ public void testAddingExistingJobParameters() {
9696
@Test
9797
public void testNonIdentifyingParameters() {
9898
this.parametersBuilder.addDate("SCHEDULE_DATE", date, false);
99-
this.parametersBuilder.addLong("LONG", new Long(1), false);
99+
this.parametersBuilder.addLong("LONG", 1L, false);
100100
this.parametersBuilder.addString("STRING", "string value", false);
101-
this.parametersBuilder.addDouble("DOUBLE", new Double(1), false);
101+
this.parametersBuilder.addDouble("DOUBLE", 1.0d, false);
102102

103103
JobParameters parameters = this.parametersBuilder.toJobParameters();
104104
assertEquals(date, parameters.getDate("SCHEDULE_DATE"));
@@ -114,9 +114,9 @@ public void testNonIdentifyingParameters() {
114114
@Test
115115
public void testToJobRuntimeParameters(){
116116
this.parametersBuilder.addDate("SCHEDULE_DATE", date);
117-
this.parametersBuilder.addLong("LONG", new Long(1));
117+
this.parametersBuilder.addLong("LONG", 1L);
118118
this.parametersBuilder.addString("STRING", "string value");
119-
this.parametersBuilder.addDouble("DOUBLE", new Double(1));
119+
this.parametersBuilder.addDouble("DOUBLE", 1.0d);
120120
JobParameters parameters = this.parametersBuilder.toJobParameters();
121121
assertEquals(date, parameters.getDate("SCHEDULE_DATE"));
122122
assertEquals(1L, parameters.getLong("LONG").longValue());
@@ -149,7 +149,7 @@ public void testCopy(){
149149
@Test
150150
public void testOrderedTypes(){
151151
this.parametersBuilder.addDate("SCHEDULE_DATE", date);
152-
this.parametersBuilder.addLong("LONG", new Long(1));
152+
this.parametersBuilder.addLong("LONG", 1L);
153153
this.parametersBuilder.addString("STRING", "string value");
154154
Iterator<String> parameters = this.parametersBuilder.toJobParameters().getParameters().keySet().iterator();
155155
assertEquals("SCHEDULE_DATE", parameters.next());
@@ -231,7 +231,7 @@ public void testGetNextJobParametersRestartable(){
231231
when(this.jobExplorer.getJobInstances("simpleJob",0,1)).thenReturn(this.jobInstanceList);
232232
when(this.jobExplorer.getJobExecutions(any())).thenReturn(this.jobExecutionList);
233233
initializeForNextJobParameters();
234-
this.parametersBuilder.addLong("NON_IDENTIFYING_LONG", new Long(1), false);
234+
this.parametersBuilder.addLong("NON_IDENTIFYING_LONG", 1L, false);
235235
this.parametersBuilder.getNextJobParameters(this.job);
236236
baseJobParametersVerify(this.parametersBuilder.toJobParameters(), 5);
237237
}
@@ -255,7 +255,7 @@ public void testMissingJobExplorer() {
255255

256256
private void initializeForNextJobParameters() {
257257
this.parametersBuilder.addDate("SCHEDULE_DATE", date);
258-
this.parametersBuilder.addLong("LONG", new Long(1));
258+
this.parametersBuilder.addLong("LONG", 1L);
259259
this.parametersBuilder.addString("STRING", "string value");
260260
}
261261

spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2018 the original author or authors.
2+
* Copyright 2008-2020 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.
@@ -86,8 +86,8 @@ public void testGetLong() {
8686

8787
@Test
8888
public void testGetDouble() {
89-
assertEquals(new Double(1.1), new Double(parameters.getDouble("double.key1")));
90-
assertEquals(new Double(2.2), new Double(parameters.getDouble("double.key2")));
89+
assertEquals(Double.valueOf(1.1d), parameters.getDouble("double.key1"));
90+
assertEquals(Double.valueOf(2.2d), parameters.getDouble("double.key2"));
9191
}
9292

9393
@Test

0 commit comments

Comments
 (0)