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

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

Lines changed: 10 additions & 10 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.
@@ -38,7 +38,7 @@
3838
*/
3939
public class StepExecutionTests {
4040

41-
private StepExecution execution = newStepExecution(new StepSupport("stepName"), new Long(23));
41+
private StepExecution execution = newStepExecution(new StepSupport("stepName"), 23L);
4242

4343
private StepExecution blankExecution = newStepExecution(new StepSupport("blank"), null);
4444

@@ -199,26 +199,26 @@ public void testEqualsWithSameName() throws Exception {
199199
@Test
200200
public void testEqualsWithSameIdentifier() throws Exception {
201201
Step step = new StepSupport("stepName");
202-
Entity stepExecution1 = newStepExecution(step, new Long(11));
203-
Entity stepExecution2 = newStepExecution(step, new Long(11));
202+
Entity stepExecution1 = newStepExecution(step, 11L);
203+
Entity stepExecution2 = newStepExecution(step, 11L);
204204
assertEquals(stepExecution1, stepExecution2);
205205
}
206206

207207
@Test
208208
public void testEqualsWithNull() throws Exception {
209-
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
209+
Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L);
210210
assertFalse(stepExecution.equals(null));
211211
}
212212

213213
@Test
214214
public void testEqualsWithNullIdentifiers() throws Exception {
215-
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
215+
Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L);
216216
assertFalse(stepExecution.equals(blankExecution));
217217
}
218218

219219
@Test
220220
public void testEqualsWithNullJob() throws Exception {
221-
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
221+
Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L);
222222
assertFalse(stepExecution.equals(blankExecution));
223223
}
224224

@@ -229,16 +229,16 @@ public void testEqualsWithSelf() throws Exception {
229229

230230
@Test
231231
public void testEqualsWithDifferent() throws Exception {
232-
Entity stepExecution = newStepExecution(new StepSupport("foo"), new Long(13));
232+
Entity stepExecution = newStepExecution(new StepSupport("foo"), 13L);
233233
assertFalse(execution.equals(stepExecution));
234234
}
235235

236236
@Test
237237
public void testEqualsWithNullStepId() throws Exception {
238238
Step step = new StepSupport("name");
239-
execution = newStepExecution(step, new Long(31));
239+
execution = newStepExecution(step, 31L);
240240
assertEquals("name", execution.getStepName());
241-
StepExecution stepExecution = newStepExecution(step, new Long(31));
241+
StepExecution stepExecution = newStepExecution(step, 31L);
242242
assertEquals(stepExecution.getJobExecutionId(), execution.getJobExecutionId());
243243
assertTrue(execution.equals(stepExecution));
244244
}

spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java

Lines changed: 2 additions & 2 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.
@@ -247,7 +247,7 @@ public void testFaultTolerantStep() throws Exception {
247247
Object step = fb.getObject();
248248
assertTrue(step instanceof TaskletStep);
249249
Object throttleLimit = ReflectionTestUtils.getField(ReflectionTestUtils.getField(step, "stepOperations"), "throttleLimit");
250-
assertEquals(new Integer(10), throttleLimit);
250+
assertEquals(Integer.valueOf(10), throttleLimit);
251251
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
252252
assertTrue(tasklet instanceof ChunkOrientedTasklet<?>);
253253
assertFalse((Boolean) ReflectionTestUtils.getField(tasklet, "buffering"));

spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2009 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.
@@ -89,7 +89,7 @@ public void testTaskletStepAttributes() throws Exception {
8989
TaskletStep bean = (TaskletStep) factory.getObject();
9090
assertEquals("wrong start-limit:", 25, bean.getStartLimit());
9191
Object throttleLimit = ReflectionTestUtils.getField(factory, "throttleLimit");
92-
assertEquals(new Integer(10), throttleLimit);
92+
assertEquals(Integer.valueOf(10), throttleLimit);
9393
}
9494

9595
@Test

spring-batch-core/src/test/java/org/springframework/batch/core/converter/DefaultJobParametersConverterTests.java

Lines changed: 2 additions & 2 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.
@@ -254,7 +254,7 @@ public void testGetParametersWithVeryRoundDouble() throws Exception {
254254
public void testGetProperties() throws Exception {
255255

256256
JobParameters parameters = new JobParametersBuilder().addDate("schedule.date", dateFormat.parse("01/23/2008"))
257-
.addString("job.key", "myKey").addLong("vendor.id", new Long(33243243)).addDouble("double.key", 1.23)
257+
.addString("job.key", "myKey").addLong("vendor.id", 33243243L).addDouble("double.key", 1.23)
258258
.toJobParameters();
259259

260260
Properties props = factory.getProperties(parameters);

spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.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.
@@ -76,7 +76,7 @@ public class CommandLineJobRunnerTests {
7676

7777
@Before
7878
public void setUp() throws Exception {
79-
JobExecution jobExecution = new JobExecution(null, new Long(1), null, null);
79+
JobExecution jobExecution = new JobExecution(null, 1L, null, null);
8080
ExitStatus exitStatus = ExitStatus.COMPLETED;
8181
jobExecution.setExitStatus(exitStatus);
8282
StubJobLauncher.jobExecution = jobExecution;

spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/DataFieldMaxValueJobParametersIncrementerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void testGetNext() {
7070

7171
// then
7272
Long runId = nextParameters.getLong("run.id");
73-
Assert.assertEquals(new Long(10) ,runId);
73+
Assert.assertEquals(Long.valueOf(10L) ,runId);
7474
}
7575

7676
@Test
@@ -89,7 +89,7 @@ public void testGetNextAppend() {
8989
// then
9090
Long runId = nextParameters.getLong("run.id");
9191
String foo = nextParameters.getString("foo");
92-
Assert.assertEquals(new Long(10) ,runId);
92+
Assert.assertEquals(Long.valueOf(10L) ,runId);
9393
Assert.assertEquals("bar" ,foo);
9494
}
9595

@@ -108,6 +108,6 @@ public void testGetNextOverride() {
108108

109109
// then
110110
Long runId = nextParameters.getLong("run.id");
111-
Assert.assertEquals(new Long(10) ,runId);
111+
Assert.assertEquals(Long.valueOf(10L) ,runId);
112112
}
113113
}

0 commit comments

Comments
 (0)