Skip to content

Commit 4dea8c2

Browse files
scordiofmbenhassine
authored andcommitted
Minor refactoring
* Remove unneeded exception declarations * Collapse catch blocks * Replace string concatenation with builder append
1 parent 0273441 commit 4dea8c2

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapper.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,7 @@ private T getBean() {
246246
try {
247247
return type.newInstance();
248248
}
249-
catch (InstantiationException e) {
250-
ReflectionUtils.handleReflectionException(e);
251-
}
252-
catch (IllegalAccessException e) {
249+
catch (InstantiationException | IllegalAccessException e) {
253250
ReflectionUtils.handleReflectionException(e);
254251
}
255252
// should not happen
@@ -370,10 +367,7 @@ private Object getPropertyValue(Object bean, String nestedName) {
370367
nestedValue = wrapper.getPropertyType(nestedName).newInstance();
371368
wrapper.setPropertyValue(nestedName, nestedValue);
372369
}
373-
catch (InstantiationException e) {
374-
ReflectionUtils.handleReflectionException(e);
375-
}
376-
catch (IllegalAccessException e) {
370+
catch (InstantiationException | IllegalAccessException e) {
377371
ReflectionUtils.handleReflectionException(e);
378372
}
379373
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class RecursiveCollectionLineAggregator<T> implements LineAggregator<Coll
3030

3131
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
3232

33-
private LineAggregator<T> delegate = new PassThroughLineAggregator<T>();
33+
private LineAggregator<T> delegate = new PassThroughLineAggregator<>();
3434

3535
/**
3636
* Public setter for the {@link LineAggregator} to use on single items, that
@@ -47,13 +47,13 @@ public void setDelegate(LineAggregator<T> delegate) {
4747
* (non-Javadoc)
4848
* @see org.springframework.batch.item.file.transform.LineAggregator#aggregate(java.lang.Object)
4949
*/
50-
@Override
50+
@Override
5151
public String aggregate(Collection<T> items) {
5252
StringBuilder builder = new StringBuilder();
5353
for (T value : items) {
54-
builder.append(delegate.aggregate(value) + LINE_SEPARATOR);
54+
builder.append(delegate.aggregate(value)).append(LINE_SEPARATOR);
5555
}
56-
return builder.delete(builder.length()-LINE_SEPARATOR.length(),builder.length()).toString();
56+
return builder.delete(builder.length() - LINE_SEPARATOR.length(), builder.length()).toString();
5757
}
5858

5959
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public IteratorItemReader(Iterator<T> iterator) {
6464
* iterator provided.
6565
*/
6666
@Override
67-
public T read() throws Exception, UnexpectedInputException, ParseException {
67+
public T read() {
6868
if (iterator.hasNext())
6969
return iterator.next();
7070
else

0 commit comments

Comments
 (0)