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
This commit is contained in:
Mark Bonnekessel
2021-01-28 20:22:04 +01:00
committed by Mahmoud Ben Hassine
parent a90389ff0d
commit 0c4c660529
2 changed files with 38 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2019 the original author or authors.
* Copyright 2006-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.
@@ -432,6 +432,14 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
}
return this;
}
/**
* Override parent method to prevent creation of a new FaultTolerantStepBuilder
*/
@Override
public FaultTolerantStepBuilder<I, O> faultTolerant() {
return this;
}
protected ChunkProvider<I> createChunkProvider() {

View File

@@ -0,0 +1,29 @@
/*
* Copyright 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.step.builder;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class FaultTolerantStepBuilderTests {
@Test
public void faultTolerantReturnsSameInstance() {
FaultTolerantStepBuilder<Object, Object> builder = new FaultTolerantStepBuilder<>(new StepBuilder("test"));
assertEquals(builder, builder.faultTolerant());
}
}