Skip to content

Commit c165d5f

Browse files
benelogfmbenhassine
authored andcommitted
Fix constructor of JsonItemReader to call setExecutionContextName()
Resolves #3681
1 parent 4a9001e commit c165d5f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JsonItemReader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018 the original author or authors.
2+
* Copyright 2018-2020 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.
@@ -24,6 +24,7 @@
2424
import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader;
2525
import org.springframework.core.io.Resource;
2626
import org.springframework.util.Assert;
27+
import org.springframework.util.ClassUtils;
2728

2829
/**
2930
* {@link ItemStreamReader} implementation that reads Json objects from a
@@ -69,6 +70,7 @@ public JsonItemReader(Resource resource, JsonObjectReader<T> jsonObjectReader) {
6970
Assert.notNull(jsonObjectReader, "The json object reader must not be null.");
7071
this.resource = resource;
7172
this.jsonObjectReader = jsonObjectReader;
73+
setExecutionContextName(ClassUtils.getShortName(JsonItemReader.class));
7274
}
7375

7476
/**

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/json/JsonItemReaderTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018 the original author or authors.
2+
* Copyright 2018-2020 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.
@@ -104,6 +104,7 @@ public void testReadItem() throws Exception {
104104
itemReader = new JsonItemReader<>(resource, this.jsonObjectReader);
105105

106106
// when
107+
itemReader.open(new ExecutionContext());
107108
itemReader.read();
108109

109110
// then

0 commit comments

Comments
 (0)