Skip to content

Commit 0a0a2ec

Browse files
benelogfmbenhassine
authored andcommitted
Fix constructor of JsonItemReader to call setExecutionContextName()
Resolves #3681
1 parent e398c3e commit 0a0a2ec

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-2019 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.
@@ -25,6 +25,7 @@
2525
import org.springframework.core.io.Resource;
2626
import org.springframework.lang.Nullable;
2727
import org.springframework.util.Assert;
28+
import org.springframework.util.ClassUtils;
2829

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

7577
/**

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)