From f995c83b1698f3686df98de9f3610972760dc796 Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Thu, 12 Aug 2021 22:12:00 +0200 Subject: [PATCH] Extract count key as constant in ResourcesItemReader --- .../batch/item/file/ResourcesItemReader.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java index 30e9df74c..372c8b90b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2018 the original author or authors. + * Copyright 2009-2021 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. @@ -48,6 +48,8 @@ import java.util.concurrent.atomic.AtomicInteger; */ public class ResourcesItemReader extends AbstractItemStreamItemReader { + private static final String COUNT_KEY = "COUNT"; + private Resource[] resources = new Resource[0]; private AtomicInteger counter = new AtomicInteger(0); @@ -85,13 +87,13 @@ public class ResourcesItemReader extends AbstractItemStreamItemReader @Override public void open(ExecutionContext executionContext) throws ItemStreamException { super.open(executionContext); - counter.set(executionContext.getInt(getExecutionContextKey("COUNT"), 0)); + counter.set(executionContext.getInt(getExecutionContextKey(COUNT_KEY), 0)); } @Override public void update(ExecutionContext executionContext) throws ItemStreamException { super.update(executionContext); - executionContext.putInt(getExecutionContextKey("COUNT"), counter.get()); + executionContext.putInt(getExecutionContextKey(COUNT_KEY), counter.get()); } }