Skip to content

Commit a43d3a5

Browse files
marbon87fmbenhassine
authored andcommitted
Override SimpleStepBuilder.faultTolerant() in FaultTolerantStepBuilder
Override SimpleStepBuilder.faultTolerant() in FaultTolerantStepBuilder to prevent creation of a new FaultTolerantStepBuilder when calling faultTolerant() on an existing FaultTolerantStepBuilder. Otherwise configuration, like chunkListeners, are lost. Issue #3840
1 parent 58e82a5 commit a43d3a5

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2019 the original author or authors.
2+
* Copyright 2006-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.
@@ -432,6 +432,14 @@ public AbstractTaskletStepBuilder<SimpleStepBuilder<I, O>> stream(ItemStream str
432432
}
433433
return this;
434434
}
435+
436+
/**
437+
* Override parent method to prevent creation of a new FaultTolerantStepBuilder
438+
*/
439+
@Override
440+
public FaultTolerantStepBuilder<I, O> faultTolerant() {
441+
return this;
442+
}
435443

436444
protected ChunkProvider<I> createChunkProvider() {
437445

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.batch.core.step.builder;
17+
18+
import org.junit.Test;
19+
20+
import static org.junit.Assert.assertEquals;
21+
22+
public class FaultTolerantStepBuilderTests {
23+
24+
@Test
25+
public void faultTolerantReturnsSameInstance() {
26+
FaultTolerantStepBuilder<Object, Object> builder = new FaultTolerantStepBuilder<>(new StepBuilder("test"));
27+
assertEquals(builder, builder.faultTolerant());
28+
}
29+
}

0 commit comments

Comments
 (0)