Skip to content

Commit f995c83

Browse files
committed
Extract count key as constant in ResourcesItemReader
1 parent 1b82947 commit f995c83

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2018 the original author or authors.
2+
* Copyright 2009-2021 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.
@@ -48,6 +48,8 @@
4848
*/
4949
public class ResourcesItemReader extends AbstractItemStreamItemReader<Resource> {
5050

51+
private static final String COUNT_KEY = "COUNT";
52+
5153
private Resource[] resources = new Resource[0];
5254

5355
private AtomicInteger counter = new AtomicInteger(0);
@@ -85,13 +87,13 @@ public synchronized Resource read() throws Exception {
8587
@Override
8688
public void open(ExecutionContext executionContext) throws ItemStreamException {
8789
super.open(executionContext);
88-
counter.set(executionContext.getInt(getExecutionContextKey("COUNT"), 0));
90+
counter.set(executionContext.getInt(getExecutionContextKey(COUNT_KEY), 0));
8991
}
9092

9193
@Override
9294
public void update(ExecutionContext executionContext) throws ItemStreamException {
9395
super.update(executionContext);
94-
executionContext.putInt(getExecutionContextKey("COUNT"), counter.get());
96+
executionContext.putInt(getExecutionContextKey(COUNT_KEY), counter.get());
9597
}
9698

9799
}

0 commit comments

Comments
 (0)