From c5b4f1a7774e5744b01fd56012bc15b42bd42e30 Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Mon, 12 Jun 2023 16:17:32 +0200 Subject: [PATCH] Remove unnecessary boxing/unboxing --- .../core/configuration/xml/AbstractStepParser.java | 2 +- .../core/configuration/xml/ChunkElementParser.java | 11 ++++++----- .../core/configuration/xml/CoreNamespaceUtils.java | 5 +++-- .../batch/core/configuration/xml/JobParser.java | 5 +++-- .../core/configuration/xml/StepListenerParser.java | 5 +++-- .../configuration/xml/StepParserStepFactoryBean.java | 2 +- .../batch/core/configuration/xml/TaskletParser.java | 2 +- .../core/converter/DefaultJobParametersConverter.java | 2 +- .../core/converter/JsonJobParametersConverter.java | 2 +- .../core/launch/support/SimpleJvmExitCodeMapper.java | 5 +++-- .../core/repository/dao/JdbcJobExecutionDao.java | 2 +- .../batch/core/JobParametersBuilderTests.java | 4 ++-- .../xml/StepParserStepFactoryBeanTests.java | 4 ++-- .../batch/core/configuration/xml/StepParserTests.java | 4 ++-- .../dao/AbstractExecutionContextSerializerTests.java | 4 ++-- .../repository/dao/AbstractJobInstanceDaoTests.java | 4 ++-- .../interceptor/RepeatOperationsInterceptor.java | 5 +++-- .../batch/support/IntArrayPropertyEditor.java | 4 ++-- .../ColumnMapExecutionContextRowMapperTests.java | 11 ++++++----- .../item/file/FlatFileItemReaderCommonTests.java | 2 +- .../file/MultiResourceItemReaderFlatFileTests.java | 2 +- .../file/builder/FlatFileItemReaderBuilderTests.java | 6 +++--- .../builder/MultiResourceItemReaderBuilderTests.java | 5 +++-- .../ClassifierCompositeItemProcessorTests.java | 7 ++++--- .../interceptor/RepeatOperationsInterceptorTests.java | 4 ++-- .../batch/sample/SkipSampleFunctionalTests.java | 6 +++--- 26 files changed, 62 insertions(+), 53 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java index 168bfa5f0..c12eaf863 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java @@ -172,7 +172,7 @@ public abstract class AbstractStepParser { String isAbstract = stepElement.getAttribute("abstract"); if (StringUtils.hasText(isAbstract)) { - bd.setAbstract(Boolean.valueOf(isAbstract)); + bd.setAbstract(Boolean.parseBoolean(isAbstract)); } String jobRepositoryRef = stepElement.getAttribute(JOB_REPO_ATTR); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/ChunkElementParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/ChunkElementParser.java index 9eca08f0e..15830607d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/ChunkElementParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/ChunkElementParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -42,6 +42,7 @@ import org.springframework.util.xml.DomUtils; * Internal parser for the <chunk/> element inside a step. * * @author Thomas Risberg + * @author Mahmoud Ben Hassine * @since 2.0 */ public class ChunkElementParser { @@ -141,7 +142,7 @@ public class ChunkElementParser { if (!CollectionUtils.isEmpty(exceptionClassElements)) { skippableExceptions.setMergeEnabled(exceptionClassElements.get(0).hasAttribute(MERGE_ATTR) - && Boolean.valueOf(exceptionClassElements.get(0).getAttribute(MERGE_ATTR))); + && Boolean.parseBoolean(exceptionClassElements.get(0).getAttribute(MERGE_ATTR))); } // Even if there is no retryLimit, we can still accept exception // classes for an abstract parent bean definition @@ -167,7 +168,7 @@ public class ChunkElementParser { if (!CollectionUtils.isEmpty(exceptionClassElements)) { retryableExceptions.setMergeEnabled(exceptionClassElements.get(0).hasAttribute(MERGE_ATTR) - && Boolean.valueOf(exceptionClassElements.get(0).getAttribute(MERGE_ATTR))); + && Boolean.parseBoolean(exceptionClassElements.get(0).getAttribute(MERGE_ATTR))); } // Even if there is no retryLimit, we can still accept exception // classes for an abstract parent bean definition @@ -296,7 +297,7 @@ public class ChunkElementParser { parserContext.pushContainingComponent(compositeDef); ManagedList retryListenerBeans = new ManagedList<>(); retryListenerBeans.setMergeEnabled(listenersElement.hasAttribute(MERGE_ATTR) - && Boolean.valueOf(listenersElement.getAttribute(MERGE_ATTR))); + && Boolean.parseBoolean(listenersElement.getAttribute(MERGE_ATTR))); handleRetryListenerElements(parserContext, listenersElement, retryListenerBeans, enclosing); propertyValues.addPropertyValue("retryListeners", retryListenerBeans); parserContext.popAndRegisterContainingComponent(); @@ -319,7 +320,7 @@ public class ChunkElementParser { if (streamsElement != null) { ManagedList streamBeans = new ManagedList<>(); streamBeans.setMergeEnabled(streamsElement.hasAttribute(MERGE_ATTR) - && Boolean.valueOf(streamsElement.getAttribute(MERGE_ATTR))); + && Boolean.parseBoolean(streamsElement.getAttribute(MERGE_ATTR))); List streamElements = DomUtils.getChildElementsByTagName(streamsElement, "stream"); if (streamElements != null) { for (Element streamElement : streamElements) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceUtils.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceUtils.java index 2f1dcea65..2b1acc062 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceUtils.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -36,6 +36,7 @@ import java.util.Map; * * @author Thomas Risberg * @author Michael Minella + * @author Mahmoud Ben Hassine */ public class CoreNamespaceUtils { @@ -202,7 +203,7 @@ public class CoreNamespaceUtils { */ public static boolean isAbstract(Element element) { String abstractAttr = element.getAttribute("abstract"); - return StringUtils.hasText(abstractAttr) && Boolean.valueOf(abstractAttr); + return StringUtils.hasText(abstractAttr) && Boolean.parseBoolean(abstractAttr); } /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParser.java index fe946883a..8254cd66d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -36,6 +36,7 @@ import org.w3c.dom.Element; * definition for a {@link org.springframework.batch.core.Job}. * * @author Dave Syer + * @author Mahmoud Ben Hassine * */ public class JobParser extends AbstractSingleBeanDefinitionParser { @@ -135,7 +136,7 @@ public class JobParser extends AbstractSingleBeanDefinitionParser { parserContext.pushContainingComponent(compositeDef); ManagedList listeners = new ManagedList<>(); listeners.setMergeEnabled(listenersElement.hasAttribute(MERGE_ATTR) - && Boolean.valueOf(listenersElement.getAttribute(MERGE_ATTR))); + && Boolean.parseBoolean(listenersElement.getAttribute(MERGE_ATTR))); List listenerElements = DomUtils.getChildElementsByTagName(listenersElement, "listener"); for (Element listenerElement : listenerElements) { listeners.add(jobListenerParser.parse(listenerElement, parserContext)); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java index c095262db..c59a6a0a5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2023 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. @@ -34,6 +34,7 @@ import org.w3c.dom.Element; * attributes from the configuration. * * @author Dan Garrette + * @author Mahmoud Ben Hassine * @since 2.0 * @see AbstractListenerParser */ @@ -78,7 +79,7 @@ public class StepListenerParser extends AbstractListenerParser { listenerBeans = (ManagedList) propertyValues.getPropertyValue("listeners").getValue(); } listenerBeans.setMergeEnabled(listenersElement.hasAttribute(MERGE_ATTR) - && Boolean.valueOf(listenersElement.getAttribute(MERGE_ATTR))); + && Boolean.parseBoolean(listenersElement.getAttribute(MERGE_ATTR))); List listenerElements = DomUtils.getChildElementsByTagName(listenersElement, "listener"); if (listenerElements != null) { for (Element listenerElement : listenerElements) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java index f5a26c706..54ba58426 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java @@ -595,7 +595,7 @@ public class StepParserStepFactoryBean implements FactoryBean, BeanN } private boolean isTrue(Boolean b) { - return b != null && b.booleanValue(); + return b != null && b; } private boolean isPositive(Integer n) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TaskletParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TaskletParser.java index 323956f10..a1a666857 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TaskletParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TaskletParser.java @@ -212,7 +212,7 @@ public class TaskletParser { Element exceptionClassesElement = children.get(0); ManagedList list = new ManagedList<>(); list.setMergeEnabled(exceptionClassesElement.hasAttribute(MERGE_ATTR) - && Boolean.valueOf(exceptionClassesElement.getAttribute(MERGE_ATTR))); + && Boolean.parseBoolean(exceptionClassesElement.getAttribute(MERGE_ATTR))); addExceptionClasses("include", exceptionClassesElement, list, parserContext); propertyValues.addPropertyValue(propertyName, list); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java index d0776f5d1..99df62792 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java @@ -190,7 +190,7 @@ public class DefaultJobParametersConverter implements JobParametersConverter { if (tokens.length <= 2) { return true; } - return Boolean.valueOf(tokens[2]); + return Boolean.parseBoolean(tokens[2]); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/JsonJobParametersConverter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/JsonJobParametersConverter.java index 6638a3eff..c1dbe2792 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/JsonJobParametersConverter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/JsonJobParametersConverter.java @@ -111,7 +111,7 @@ public class JsonJobParametersConverter extends DefaultJobParametersConverter { } boolean parameterIdentifying = true; if (jobParameterDefinition.identifying() != null && !jobParameterDefinition.identifying().isEmpty()) { - parameterIdentifying = Boolean.valueOf(jobParameterDefinition.identifying()); + parameterIdentifying = Boolean.parseBoolean(jobParameterDefinition.identifying()); } Object parameterTypedValue = this.conversionService.convert(jobParameterDefinition.value(), parameterType); return new JobParameter(parameterTypedValue, parameterType, parameterIdentifying); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java index 7341b746d..ea560cfc3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2023 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. @@ -31,6 +31,7 @@ import org.springframework.batch.core.ExitStatus; * @author Stijn Maller * @author Lucas Ward * @author Dave Syer + * @author Mahmoud Ben Hassine */ public class SimpleJvmExitCodeMapper implements ExitCodeMapper { @@ -81,7 +82,7 @@ public class SimpleJvmExitCodeMapper implements ExitCodeMapper { logger.fatal("Error mapping exit code, generic exit status returned.", ex); } - return (statusCode != null) ? statusCode.intValue() : JVM_EXITCODE_GENERIC_ERROR; + return (statusCode != null) ? statusCode : JVM_EXITCODE_GENERIC_ERROR; } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java index 1e60a023c..cfae69280 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java @@ -390,7 +390,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements int currentVersion = getJdbcTemplate().queryForObject(getQuery(CURRENT_VERSION_JOB_EXECUTION), Integer.class, jobExecution.getId()); - if (currentVersion != jobExecution.getVersion().intValue()) { + if (currentVersion != jobExecution.getVersion()) { String status = getJdbcTemplate().queryForObject(getQuery(GET_STATUS), String.class, jobExecution.getId()); jobExecution.upgradeStatus(BatchStatus.valueOf(status)); jobExecution.setVersion(currentVersion); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java index 43374fcd0..a79efcca4 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobParametersBuilderTests.java @@ -96,7 +96,7 @@ class JobParametersBuilderTests { assertEquals(date, parameters.getDate("SCHEDULE_DATE")); assertEquals(1L, parameters.getLong("LONG").longValue()); assertEquals("string value", parameters.getString("STRING")); - assertEquals(1, parameters.getDouble("DOUBLE").doubleValue(), 1e-15); + assertEquals(1, parameters.getDouble("DOUBLE"), 1e-15); assertFalse(parameters.getParameters().get("SCHEDULE_DATE").isIdentifying()); assertFalse(parameters.getParameters().get("LONG").isIdentifying()); assertFalse(parameters.getParameters().get("STRING").isIdentifying()); @@ -112,7 +112,7 @@ class JobParametersBuilderTests { JobParameters parameters = this.parametersBuilder.toJobParameters(); assertEquals(date, parameters.getDate("SCHEDULE_DATE")); assertEquals(1L, parameters.getLong("LONG").longValue()); - assertEquals(1, parameters.getDouble("DOUBLE").doubleValue(), 1e-15); + assertEquals(1, parameters.getDouble("DOUBLE"), 1e-15); assertEquals("string value", parameters.getString("STRING")); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java index 005791906..333d52b59 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -249,7 +249,7 @@ class StepParserStepFactoryBeanTests { assertTrue(step instanceof TaskletStep); Object throttleLimit = ReflectionTestUtils.getField(ReflectionTestUtils.getField(step, "stepOperations"), "throttleLimit"); - assertEquals(Integer.valueOf(10), throttleLimit); + assertEquals(10, throttleLimit); Object tasklet = ReflectionTestUtils.getField(step, "tasklet"); assertTrue(tasklet instanceof ChunkOrientedTasklet); assertFalse((Boolean) ReflectionTestUtils.getField(tasklet, "buffering")); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java index cd962d9d6..7fe234a8a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -90,7 +90,7 @@ public class StepParserTests { TaskletStep bean = (TaskletStep) factory.getObject(); assertEquals(25, bean.getStartLimit(), "wrong start-limit:"); Object throttleLimit = ReflectionTestUtils.getField(factory, "throttleLimit"); - assertEquals(Integer.valueOf(10), throttleLimit); + assertEquals(10, throttleLimit); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java index 162ebfb59..9fdeba1d4 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java @@ -51,7 +51,7 @@ public abstract class AbstractExecutionContextSerializerTests { @Test void testSerializeAMap() throws Exception { Map m1 = new HashMap<>(); - m1.put("object1", Long.valueOf(12345L)); + m1.put("object1", 12345L); m1.put("object2", "OBJECT TWO"); // Use a date after 1971 (otherwise daylight saving screws up)... m1.put("object3", new Date(123456790123L)); @@ -141,7 +141,7 @@ public abstract class AbstractExecutionContextSerializerTests { ComplexObject o1 = new ComplexObject(); o1.setName("02345"); Map m = new HashMap<>(); - m.put("object1", Long.valueOf(12345L)); + m.put("object1", 12345L); m.put("object2", "OBJECT TWO"); o1.setMap(m); o1.setNumber(new BigDecimal("12345.67")); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobInstanceDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobInstanceDaoTests.java index 56d0de868..9f463d736 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobInstanceDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractJobInstanceDaoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2022 the original author or authors. + * Copyright 2008-2023 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. @@ -181,7 +181,7 @@ public abstract class AbstractJobInstanceDaoTests { String paramKey = "myID"; int instanceCount = 6; for (int i = 1; i <= instanceCount; i++) { - JobParameters params = new JobParametersBuilder().addLong(paramKey, Long.valueOf(i)).toJobParameters(); + JobParameters params = new JobParametersBuilder().addLong(paramKey, (long) i).toJobParameters(); dao.createJobInstance(multiInstanceJob, params); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptor.java index 9dc93e4f7..034b78e0c 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2023 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. @@ -38,6 +38,7 @@ import org.springframework.util.Assert; * representing the {@link Void#TYPE}). * * @author Dave Syer + * @author Mahmoud Ben Hassine */ public class RepeatOperationsInterceptor implements MethodInterceptor { @@ -132,7 +133,7 @@ public class RepeatOperationsInterceptor implements MethodInterceptor { * @return */ private boolean isComplete(Object result) { - return result == null || (result instanceof Boolean) && !((Boolean) result).booleanValue(); + return result == null || (result instanceof Boolean) && !(Boolean) result; } /** diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/IntArrayPropertyEditor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/IntArrayPropertyEditor.java index 5325de05d..0023bb352 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/IntArrayPropertyEditor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/IntArrayPropertyEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2023 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. @@ -27,7 +27,7 @@ public class IntArrayPropertyEditor extends PropertyEditorSupport { String[] strs = StringUtils.commaDelimitedListToStringArray(text); int[] value = new int[strs.length]; for (int i = 0; i < value.length; i++) { - value[i] = Integer.valueOf(strs[i].trim()).intValue(); + value[i] = Integer.parseInt(strs[i].trim()); } setValue(value); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/ColumnMapExecutionContextRowMapperTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/ColumnMapExecutionContextRowMapperTests.java index 0cb3c8ef5..da677d07a 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/ColumnMapExecutionContextRowMapperTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/ColumnMapExecutionContextRowMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2022 the original author or authors. + * Copyright 2008-2023 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. @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; /** * @author Lucas Ward * @author Will Schipp + * @author Mahmoud Ben Hassine */ class ColumnMapExecutionContextRowMapperTests { @@ -42,8 +43,8 @@ class ColumnMapExecutionContextRowMapperTests { mapper = new ColumnMapItemPreparedStatementSetter(); key = new LinkedHashMap<>(2); - key.put("1", Integer.valueOf(1)); - key.put("2", Integer.valueOf(2)); + key.put("1", 1); + key.put("2", 2); } @Test @@ -55,8 +56,8 @@ class ColumnMapExecutionContextRowMapperTests { @Test void testCreateSetter() throws Exception { - ps.setObject(1, Integer.valueOf(1)); - ps.setObject(2, Integer.valueOf(2)); + ps.setObject(1, 1); + ps.setObject(2, 2); mapper.setValues(key, ps); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderCommonTests.java index 5c2d1f589..aee4d125f 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderCommonTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderCommonTests.java @@ -38,7 +38,7 @@ public class FlatFileItemReaderCommonTests extends AbstractItemStreamItemReaderT @Override public Foo mapLine(String line, int lineNumber) { Foo foo = new Foo(); - foo.setValue(Integer.valueOf(line.trim())); + foo.setValue(Integer.parseInt(line.trim())); return foo; } }); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderFlatFileTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderFlatFileTests.java index 116118635..7677a35fd 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderFlatFileTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderFlatFileTests.java @@ -37,7 +37,7 @@ class MultiResourceItemReaderFlatFileTests extends AbstractItemStreamItemReaderT @Override public Foo mapLine(String line, int lineNumber) throws Exception { Foo foo = new Foo(); - foo.setValue(Integer.valueOf(line)); + foo.setValue(Integer.parseInt(line)); return foo; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/FlatFileItemReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/FlatFileItemReaderBuilderTests.java index ab970fea0..a398820ae 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/FlatFileItemReaderBuilderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/FlatFileItemReaderBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2022 the original author or authors. + * Copyright 2016-2023 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. @@ -223,8 +223,8 @@ class FlatFileItemReaderBuilderTests { .fieldSetMapper(fieldSet -> { Foo item = new Foo(); - item.setFirst(Integer.valueOf(fieldSet.readString(0).replaceAll("\\|", ""))); - item.setSecond(Integer.valueOf(fieldSet.readString(1).replaceAll("\\|", ""))); + item.setFirst(Integer.parseInt(fieldSet.readString(0).replaceAll("\\|", ""))); + item.setSecond(Integer.parseInt(fieldSet.readString(1).replaceAll("\\|", ""))); item.setThird(fieldSet.readString(2).replaceAll("\\|", "")); return item; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/MultiResourceItemReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/MultiResourceItemReaderBuilderTests.java index c6fdca043..539479c5d 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/MultiResourceItemReaderBuilderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/builder/MultiResourceItemReaderBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2022 the original author or authors. + * Copyright 2017-2023 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. @@ -35,6 +35,7 @@ import static org.mockito.Mockito.mock; /** * @author Glenn Renfro + * @author Mahmoud Ben Hassine */ class MultiResourceItemReaderBuilderTests extends AbstractItemStreamItemReaderTests { @@ -45,7 +46,7 @@ class MultiResourceItemReaderBuilderTests extends AbstractItemStreamItemReaderTe fileReader.setLineMapper((line, lineNumber) -> { Foo foo = new Foo(); - foo.setValue(Integer.valueOf(line)); + foo.setValue(Integer.parseInt(line)); return foo; }); fileReader.setSaveState(true); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessorTests.java index e3c1099b8..de0fa213d 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessorTests.java @@ -28,6 +28,7 @@ import org.springframework.lang.Nullable; /** * @author Jimmy Praet + * @author Mahmoud Ben Hassine */ class ClassifierCompositeItemProcessorTests { @@ -98,9 +99,9 @@ class ClassifierCompositeItemProcessorTests { classifier.setTypeMap(typeMap); processor.setClassifier(classifier); - assertEquals("int: 1", processor.process(Integer.valueOf(1)).toString()); - assertEquals("long: 2", processor.process(Long.valueOf(2)).toString()); - assertEquals("number: 3", processor.process(Byte.valueOf((byte) 3)).toString()); + assertEquals("int: 1", processor.process(1).toString()); + assertEquals("long: 2", processor.process(2L).toString()); + assertEquals("number: 3", processor.process((byte) 3).toString()); } } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptorTests.java index 4cdea1bfc..b2121aa38 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -249,7 +249,7 @@ class RepeatOperationsInterceptorTests { public Object service() throws Exception { count++; if (count <= maxService) { - return Integer.valueOf(count); + return count; } else { return null; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java index d50260fa5..8dd62a52f 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java @@ -283,9 +283,9 @@ class SkipSampleFunctionalTests { assertEquals(new BigDecimal("340.45"), jobExecution.getExecutionContext().get(TradeWriter.TOTAL_AMOUNT_KEY)); Map step1Execution = getStepExecutionAsMap(jobExecution, "step1"); - assertEquals(Long.valueOf(4L), step1Execution.get("COMMIT_COUNT")); - assertEquals(Long.valueOf(8L), step1Execution.get("READ_COUNT")); - assertEquals(Long.valueOf(7L), step1Execution.get("WRITE_COUNT")); + assertEquals(4L, step1Execution.get("COMMIT_COUNT")); + assertEquals(8L, step1Execution.get("READ_COUNT")); + assertEquals(7L, step1Execution.get("WRITE_COUNT")); } private void validateLaunchWithoutSkips(JobExecution jobExecution) {