Skip to content

Commit

Permalink
Don't call wrapper constructors directly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marschall committed Nov 15, 2020
1 parent f2c1296 commit 9268abc
Show file tree
Hide file tree
Showing 31 changed files with 89 additions and 89 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 the original author or authors.
* Copyright 2006-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.
Expand Down Expand Up @@ -67,7 +67,7 @@ public void testLaunchJob() throws Exception {
logger.info("Processed: " + stepExecution);
if (stepExecution.getStepName().equals("playerload")) {
// The effect of the retries
assertEquals(new Double(Math.ceil(stepExecution.getReadCount() / 10. + 1)).intValue(),
assertEquals((int) Math.ceil(stepExecution.getReadCount() / 10. + 1),
stepExecution.getCommitCount());
}
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 the original author or authors.
* Copyright 2006-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.
Expand Down Expand Up @@ -69,7 +69,7 @@ public void testMultithreadedSplit() throws Throwable {
}

try {
JobExecution execution = jobLauncher.run(job, new JobParametersBuilder().addLong("count", new Long(i))
JobExecution execution = jobLauncher.run(job, new JobParametersBuilder().addLong("count", (long) i)
.toJobParameters());
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
}
Expand Down
Expand Up @@ -475,7 +475,7 @@ private List<JobExecution> getRunningJobExecutions(String jobIdentifier) {

private Long getLongIdentifier(String jobIdentifier) {
try {
return new Long(jobIdentifier);
return Long.parseLong(jobIdentifier);
}
catch (NumberFormatException e) {
// Not an ID - must be a name
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 the original author or authors.
* Copyright 2006-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.
Expand Down Expand Up @@ -348,7 +348,7 @@ private void insertParameter(Long executionId, ParameterType type, String key,
0L, 0D, identifyingFlag};
} else if (type == ParameterType.LONG) {
args = new Object[] { executionId, key, type, "", new Timestamp(0L),
value, new Double(0), identifyingFlag};
value, 0.0d, identifyingFlag};
} else if (type == ParameterType.DOUBLE) {
args = new Object[] { executionId, key, type, "", new Timestamp(0L), 0L,
value, identifyingFlag};
Expand Down
Expand Up @@ -65,7 +65,7 @@ public int compareTo(ContextKey them) {
if(them == null) {
return 1;
}
final int idCompare = new Long(this.id).compareTo(new Long(them.id)); // JDK6 Make this Long.compare(x,y)
final int idCompare = Long.compare(this.id, them.id);
if(idCompare != 0) {
return idCompare;
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-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.
Expand All @@ -23,7 +23,7 @@
*/
public class EntityTests extends TestCase {

Entity entity = new Entity(new Long(11));
Entity entity = new Entity(11L);

/**
* Test method for {@link org.springframework.batch.core.Entity#hashCode()}.
Expand Down Expand Up @@ -54,7 +54,7 @@ public void testGetVersion() {
*/
public void testIncrementVersion() {
entity.incrementVersion();
assertEquals(new Integer(0), entity.getVersion());
assertEquals(Integer.valueOf(0), entity.getVersion());
}

/**
Expand All @@ -63,7 +63,7 @@ public void testIncrementVersion() {
public void testIncrementVersionTwice() {
entity.incrementVersion();
entity.incrementVersion();
assertEquals(new Integer(1), entity.getVersion());
assertEquals(Integer.valueOf(1), entity.getVersion());
}

/**
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2018 the original author or authors.
* Copyright 2006-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.
Expand Down Expand Up @@ -35,8 +35,8 @@
*/
public class JobExecutionTests {

private JobExecution execution = new JobExecution(new JobInstance(new Long(11), "foo"),
new Long(12), new JobParameters(), null);
private JobExecution execution = new JobExecution(new JobInstance(11L, "foo"),
12L, new JobParameters(), null);

@Test
public void testJobExecution() {
Expand Down Expand Up @@ -135,7 +135,7 @@ public void testDowngradeStatus() {
@Test
public void testGetJobId() {
assertEquals(11, execution.getJobId().longValue());
execution = new JobExecution(new JobInstance(new Long(23), "testJob"), null, new JobParameters(), null);
execution = new JobExecution(new JobInstance(23L, "testJob"), null, new JobParameters(), null);
assertEquals(23, execution.getJobId().longValue());
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2014 the original author or authors.
* Copyright 2006-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.
Expand Down Expand Up @@ -27,15 +27,15 @@
*/
public class JobInstanceTests {

private JobInstance instance = new JobInstance(new Long(11), "job");
private JobInstance instance = new JobInstance(11L, "job");

/**
* Test method for
* {@link org.springframework.batch.core.JobInstance#getJobName()}.
*/
@Test
public void testGetName() {
instance = new JobInstance(new Long(1), "foo");
instance = new JobInstance(1L, "foo");
assertEquals("foo", instance.getJobName());
}

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

@Test
public void testSerialization() {
instance = new JobInstance(new Long(1), "jobName");
instance = new JobInstance(1L, "jobName");

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

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2018 the original author or authors.
* Copyright 2008-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.
Expand Down Expand Up @@ -96,9 +96,9 @@ public void testAddingExistingJobParameters() {
@Test
public void testNonIdentifyingParameters() {
this.parametersBuilder.addDate("SCHEDULE_DATE", date, false);
this.parametersBuilder.addLong("LONG", new Long(1), false);
this.parametersBuilder.addLong("LONG", 1L, false);
this.parametersBuilder.addString("STRING", "string value", false);
this.parametersBuilder.addDouble("DOUBLE", new Double(1), false);
this.parametersBuilder.addDouble("DOUBLE", 1.0d, false);

JobParameters parameters = this.parametersBuilder.toJobParameters();
assertEquals(date, parameters.getDate("SCHEDULE_DATE"));
Expand All @@ -114,9 +114,9 @@ public void testNonIdentifyingParameters() {
@Test
public void testToJobRuntimeParameters(){
this.parametersBuilder.addDate("SCHEDULE_DATE", date);
this.parametersBuilder.addLong("LONG", new Long(1));
this.parametersBuilder.addLong("LONG", 1L);
this.parametersBuilder.addString("STRING", "string value");
this.parametersBuilder.addDouble("DOUBLE", new Double(1));
this.parametersBuilder.addDouble("DOUBLE", 1.0d);
JobParameters parameters = this.parametersBuilder.toJobParameters();
assertEquals(date, parameters.getDate("SCHEDULE_DATE"));
assertEquals(1L, parameters.getLong("LONG").longValue());
Expand Down Expand Up @@ -149,7 +149,7 @@ public void testCopy(){
@Test
public void testOrderedTypes(){
this.parametersBuilder.addDate("SCHEDULE_DATE", date);
this.parametersBuilder.addLong("LONG", new Long(1));
this.parametersBuilder.addLong("LONG", 1L);
this.parametersBuilder.addString("STRING", "string value");
Iterator<String> parameters = this.parametersBuilder.toJobParameters().getParameters().keySet().iterator();
assertEquals("SCHEDULE_DATE", parameters.next());
Expand Down Expand Up @@ -231,7 +231,7 @@ public void testGetNextJobParametersRestartable(){
when(this.jobExplorer.getJobInstances("simpleJob",0,1)).thenReturn(this.jobInstanceList);
when(this.jobExplorer.getJobExecutions(any())).thenReturn(this.jobExecutionList);
initializeForNextJobParameters();
this.parametersBuilder.addLong("NON_IDENTIFYING_LONG", new Long(1), false);
this.parametersBuilder.addLong("NON_IDENTIFYING_LONG", 1L, false);
this.parametersBuilder.getNextJobParameters(this.job);
baseJobParametersVerify(this.parametersBuilder.toJobParameters(), 5);
}
Expand All @@ -255,7 +255,7 @@ public void testMissingJobExplorer() {

private void initializeForNextJobParameters() {
this.parametersBuilder.addDate("SCHEDULE_DATE", date);
this.parametersBuilder.addLong("LONG", new Long(1));
this.parametersBuilder.addLong("LONG", 1L);
this.parametersBuilder.addString("STRING", "string value");
}

Expand Down
Expand Up @@ -86,8 +86,8 @@ public void testGetLong() {

@Test
public void testGetDouble() {
assertEquals(new Double(1.1), new Double(parameters.getDouble("double.key1")));
assertEquals(new Double(2.2), new Double(parameters.getDouble("double.key2")));
assertEquals(Double.valueOf(1.1d), parameters.getDouble("double.key1"));
assertEquals(Double.valueOf(2.2d), parameters.getDouble("double.key2"));
}

@Test
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2014 the original author or authors.
* Copyright 2006-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.
Expand Down Expand Up @@ -38,7 +38,7 @@
*/
public class StepExecutionTests {

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

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

Expand Down Expand Up @@ -199,26 +199,26 @@ public void testEqualsWithSameName() throws Exception {
@Test
public void testEqualsWithSameIdentifier() throws Exception {
Step step = new StepSupport("stepName");
Entity stepExecution1 = newStepExecution(step, new Long(11));
Entity stepExecution2 = newStepExecution(step, new Long(11));
Entity stepExecution1 = newStepExecution(step, 11L);
Entity stepExecution2 = newStepExecution(step, 11L);
assertEquals(stepExecution1, stepExecution2);
}

@Test
public void testEqualsWithNull() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L);
assertFalse(stepExecution.equals(null));
}

@Test
public void testEqualsWithNullIdentifiers() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L);
assertFalse(stepExecution.equals(blankExecution));
}

@Test
public void testEqualsWithNullJob() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("stepName"), new Long(11));
Entity stepExecution = newStepExecution(new StepSupport("stepName"), 11L);
assertFalse(stepExecution.equals(blankExecution));
}

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

@Test
public void testEqualsWithDifferent() throws Exception {
Entity stepExecution = newStepExecution(new StepSupport("foo"), new Long(13));
Entity stepExecution = newStepExecution(new StepSupport("foo"), 13L);
assertFalse(execution.equals(stepExecution));
}

@Test
public void testEqualsWithNullStepId() throws Exception {
Step step = new StepSupport("name");
execution = newStepExecution(step, new Long(31));
execution = newStepExecution(step, 31L);
assertEquals("name", execution.getStepName());
StepExecution stepExecution = newStepExecution(step, new Long(31));
StepExecution stepExecution = newStepExecution(step, 31L);
assertEquals(stepExecution.getJobExecutionId(), execution.getJobExecutionId());
assertTrue(execution.equals(stepExecution));
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-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.
Expand Down Expand Up @@ -247,7 +247,7 @@ public void testFaultTolerantStep() throws Exception {
Object step = fb.getObject();
assertTrue(step instanceof TaskletStep);
Object throttleLimit = ReflectionTestUtils.getField(ReflectionTestUtils.getField(step, "stepOperations"), "throttleLimit");
assertEquals(new Integer(10), throttleLimit);
assertEquals(Integer.valueOf(10), throttleLimit);
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
assertTrue(tasklet instanceof ChunkOrientedTasklet<?>);
assertFalse((Boolean) ReflectionTestUtils.getField(tasklet, "buffering"));
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2009 the original author or authors.
* Copyright 2006-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.
Expand Down Expand Up @@ -89,7 +89,7 @@ public void testTaskletStepAttributes() throws Exception {
TaskletStep bean = (TaskletStep) factory.getObject();
assertEquals("wrong start-limit:", 25, bean.getStartLimit());
Object throttleLimit = ReflectionTestUtils.getField(factory, "throttleLimit");
assertEquals(new Integer(10), throttleLimit);
assertEquals(Integer.valueOf(10), throttleLimit);
}

@Test
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2014 the original author or authors.
* Copyright 2006-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.
Expand Down Expand Up @@ -254,7 +254,7 @@ public void testGetParametersWithVeryRoundDouble() throws Exception {
public void testGetProperties() throws Exception {

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

Properties props = factory.getProperties(parameters);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 the original author or authors.
* Copyright 2006-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.
Expand Down Expand Up @@ -76,7 +76,7 @@ public class CommandLineJobRunnerTests {

@Before
public void setUp() throws Exception {
JobExecution jobExecution = new JobExecution(null, new Long(1), null, null);
JobExecution jobExecution = new JobExecution(null, 1L, null, null);
ExitStatus exitStatus = ExitStatus.COMPLETED;
jobExecution.setExitStatus(exitStatus);
StubJobLauncher.jobExecution = jobExecution;
Expand Down
Expand Up @@ -70,7 +70,7 @@ public void testGetNext() {

// then
Long runId = nextParameters.getLong("run.id");
Assert.assertEquals(new Long(10) ,runId);
Assert.assertEquals(Long.valueOf(10L) ,runId);
}

@Test
Expand All @@ -89,7 +89,7 @@ public void testGetNextAppend() {
// then
Long runId = nextParameters.getLong("run.id");
String foo = nextParameters.getString("foo");
Assert.assertEquals(new Long(10) ,runId);
Assert.assertEquals(Long.valueOf(10L) ,runId);
Assert.assertEquals("bar" ,foo);
}

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

// then
Long runId = nextParameters.getLong("run.id");
Assert.assertEquals(new Long(10) ,runId);
Assert.assertEquals(Long.valueOf(10L) ,runId);
}
}

0 comments on commit 9268abc

Please sign in to comment.