Skip to content

Commit 241e37e

Browse files
committed
Remove concatenation with empty string
1 parent b5e7269 commit 241e37e

File tree

9 files changed

+27
-24
lines changed

9 files changed

+27
-24
lines changed

spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2022 the original author or authors.
2+
* Copyright 2006-2023 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.
@@ -31,6 +31,7 @@
3131

3232
/**
3333
* @author Dave Syer
34+
* @author Mahmoud Ben Hassine
3435
*
3536
*/
3637
class ChunkMonitorTests {
@@ -49,7 +50,7 @@ void setUp() {
4950
@Nullable
5051
@Override
5152
public String read() throws Exception, UnexpectedInputException, ParseException {
52-
return "" + (count++);
53+
return String.valueOf(count++);
5354
}
5455
});
5556
monitor.registerItemStream(new ItemStreamSupport() {
@@ -150,7 +151,7 @@ void testUpdateWithNoStream() {
150151
@Nullable
151152
@Override
152153
public String read() throws Exception, UnexpectedInputException, ParseException {
153-
return "" + (count++);
154+
return String.valueOf(count++);
154155
}
155156
});
156157
monitor.setChunkSize(CHUNK_SIZE);

spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ void testCacheLimitWithRetry() throws Exception {
664664
@Nullable
665665
@Override
666666
public String read() {
667-
String item = "" + count;
667+
String item = String.valueOf(count);
668668
provided.add(item);
669669
count++;
670670
if (count >= 10) {

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SqlWindowingPagingQueryProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2022 the original author or authors.
2+
* Copyright 2006-2023 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.
@@ -63,7 +63,7 @@ protected Object getSubQueryAlias() {
6363
}
6464

6565
protected Object extractTableAlias() {
66-
String alias = "" + getSubQueryAlias();
66+
String alias = String.valueOf(getSubQueryAlias());
6767
if (StringUtils.hasText(alias) && alias.toUpperCase().startsWith("AS")) {
6868
alias = alias.substring(3).trim() + ".";
6969
}

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public class DefaultFieldSet implements FieldSet {
7171
public final void setNumberFormat(NumberFormat numberFormat) {
7272
this.numberFormat = numberFormat;
7373
if (numberFormat instanceof DecimalFormat) {
74-
grouping = "" + ((DecimalFormat) numberFormat).getDecimalFormatSymbols().getGroupingSeparator();
75-
decimal = "" + ((DecimalFormat) numberFormat).getDecimalFormatSymbols().getDecimalSeparator();
74+
grouping = String.valueOf(((DecimalFormat) numberFormat).getDecimalFormatSymbols().getGroupingSeparator());
75+
decimal = String.valueOf(((DecimalFormat) numberFormat).getDecimalFormatSymbols().getDecimalSeparator());
7676
}
7777
}
7878

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DelimitedLineTokenizer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2022 the original author or authors.
2+
* Copyright 2006-2023 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.
@@ -34,6 +34,7 @@
3434
* @author Dave Syer
3535
* @author Michael Minella
3636
* @author Olivier Bourgain
37+
* @author Mahmoud Ben Hassine
3738
*/
3839
public class DelimitedLineTokenizer extends AbstractLineTokenizer implements InitializingBean {
3940

@@ -121,8 +122,8 @@ public void setIncludedFields(int... includedFields) {
121122
*/
122123
public void setQuoteCharacter(char quoteCharacter) {
123124
this.quoteCharacter = quoteCharacter;
124-
this.quoteString = "" + quoteCharacter;
125-
this.escapedQuoteString = "" + quoteCharacter + quoteCharacter;
125+
this.quoteString = String.valueOf(quoteCharacter);
126+
this.escapedQuoteString = String.valueOf(quoteCharacter) + quoteCharacter;
126127
}
127128

128129
/**

spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplateAsynchronousTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void testThrottleLimit() {
169169
assertNotSame(threadName, Thread.currentThread().getName());
170170
Trade item = provider.read();
171171
threadNames.add(Thread.currentThread().getName() + " : " + item);
172-
items.add("" + item);
172+
items.add(String.valueOf(item));
173173
if (item != null) {
174174
processor.write(Chunk.of(item));
175175
// Do some more I/O

spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplateBulkAsynchronousTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ void setUp() {
8888
@Override
8989
public RepeatStatus doInIteration(RepeatContext context) throws Exception {
9090
int position = count.incrementAndGet();
91-
String item = position <= total ? "" + position : null;
92-
items.add("" + item);
91+
String item = position <= total ? String.valueOf(position) : null;
92+
items.add(item);
9393
if (item != null) {
9494
beBusy();
9595
}
@@ -121,7 +121,7 @@ void tearDown() {
121121
void testThrottleLimit() {
122122

123123
template.iterate(callback);
124-
int frequency = Collections.frequency(items, "null");
124+
int frequency = Collections.frequency(items, null);
125125
assertEquals(total, items.size() - frequency);
126126
assertTrue(frequency > 1);
127127
assertTrue(frequency <= throttleLimit + 1);
@@ -134,7 +134,7 @@ void testThrottleLimitEarlyFinish() {
134134
early = 2;
135135

136136
template.iterate(callback);
137-
int frequency = Collections.frequency(items, "null");
137+
int frequency = Collections.frequency(items, null);
138138
assertEquals(total, items.size() - frequency);
139139
assertTrue(frequency > 1);
140140
assertTrue(frequency <= throttleLimit + 1);
@@ -158,7 +158,7 @@ void testThrottleLimitEarlyFinishThreadStarvation() {
158158
template.setTaskExecutor(taskExecutor);
159159

160160
template.iterate(callback);
161-
int frequency = Collections.frequency(items, "null");
161+
int frequency = Collections.frequency(items, null);
162162
// Extra tasks will be submitted before the termination is detected
163163
assertEquals(total, items.size() - frequency);
164164
assertTrue(frequency <= throttleLimit + 1);
@@ -182,7 +182,7 @@ void testThrottleLimitEarlyFinishOneThread() {
182182
template.setTaskExecutor(taskExecutor);
183183

184184
template.iterate(callback);
185-
int frequency = Collections.frequency(items, "null");
185+
int frequency = Collections.frequency(items, null);
186186
assertEquals(total, items.size() - frequency);
187187
assertTrue(frequency <= throttleLimit + 1);
188188

@@ -195,7 +195,7 @@ void testThrottleLimitWithEarlyCompletion() {
195195
template.setCompletionPolicy(new SimpleCompletionPolicy(10));
196196

197197
template.iterate(callback);
198-
int frequency = Collections.frequency(items, "null");
198+
int frequency = Collections.frequency(items, null);
199199
assertEquals(10, items.size() - frequency);
200200
assertEquals(0, frequency);
201201

@@ -208,7 +208,7 @@ void testThrottleLimitWithError() {
208208

209209
Exception exception = assertThrows(Exception.class, () -> template.iterate(callback));
210210
assertEquals("Planned", exception.getMessage());
211-
int frequency = Collections.frequency(items, "null");
211+
int frequency = Collections.frequency(items, null);
212212
assertEquals(0, frequency);
213213

214214
}

spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/JmsIntegrationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2022 the original author or authors.
2+
* Copyright 2006-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -35,6 +35,7 @@
3535

3636
/**
3737
* @author Dave Syer
38+
* @author Mahmoud Ben Hassine
3839
*
3940
*/
4041
@SpringJUnitConfig
@@ -73,7 +74,7 @@ void testLaunchJob() throws Exception {
7374
// execution are old and we need to
7475
// pull them back out of the repository...
7576
stepExecution = jobExplorer.getStepExecution(jobExecution.getId(), stepExecution.getId());
76-
logger.debug("" + stepExecution);
77+
logger.debug(String.valueOf(stepExecution));
7778
assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
7879
}
7980
}

spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/FlatFileCustomerCreditDao.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2022 the original author or authors.
2+
* Copyright 2006-2023 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.
@@ -46,7 +46,7 @@ public void writeCredit(CustomerCredit customerCredit) throws Exception {
4646
open(new ExecutionContext());
4747
}
4848

49-
String line = "" + customerCredit.getName() + separator + customerCredit.getCredit();
49+
String line = customerCredit.getName() + separator + customerCredit.getCredit();
5050

5151
itemWriter.write(Chunk.of(line));
5252
}

0 commit comments

Comments
 (0)