Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting item processor property with lambda error #3749

Closed
riane5 opened this issue Jul 21, 2020 · 3 comments
Closed

Setting item processor property with lambda error #3749

riane5 opened this issue Jul 21, 2020 · 3 comments
Labels
for: backport-to-4.2.x Issues that will be back-ported to the 4.2.x line in: core type: bug
Milestone

Comments

@riane5
Copy link

riane5 commented Jul 21, 2020

Please do a quick search on Github issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description
Setting processor property with lambda error
My code is as follows

 stepBuilderFactory.get("step_name_01")
                .allowStartIfComplete(true)
                .<String, String>chunk(2)
                .reader(itemReader())
                // use lambda 
                .processor((Function<String, String>) (in) -> "hello " + in)
                .writer(list -> list.forEach(System.out::println))
                .faultTolerant() // this will new FaultTolerantStepBuilder
                .skip(MyBatchException.class)
                .skipLimit(1)
                .build();

So I found that the item processor did not work,because the itemprocessorfunction property of Faulttolerantstepbuilder is null,its itemProcessor property is null

protected FaultTolerantStepBuilder(SimpleStepBuilder<I, O> parent) {
           super(parent);
}
protected SimpleStepBuilder(SimpleStepBuilder<I, O> parent) {
		super(parent);
		this.chunkSize = parent.chunkSize;
		this.completionPolicy = parent.completionPolicy;
		this.chunkOperations = parent.chunkOperations;
		this.reader = parent.reader;
		this.writer = parent.writer;
		this.processor = parent.processor;
		this.itemListeners = parent.itemListeners;
		this.readerTransactionalQueue = parent.readerTransactionalQueue;
}

Why is the itemprocessorfunction attribute not synchronized in the constructor ??????
Should I add the following code to the constructor ??
this.itemprocessorfunction =parent.itemprocessorfunction

Thank you

@riane5 riane5 added status: waiting-for-triage Issues that we did not analyse yet type: bug labels Jul 21, 2020
@fmbenhassine fmbenhassine added in: core and removed status: waiting-for-triage Issues that we did not analyse yet labels Apr 14, 2021
@fmbenhassine fmbenhassine added this to the 4.3.3 milestone Apr 14, 2021
@fmbenhassine fmbenhassine added the for: backport-to-4.2.x Issues that will be back-ported to the 4.2.x line label Apr 14, 2021
@fmbenhassine
Copy link
Contributor

Thank you for opening this issue. This is indeed a bug in SimpleStepBuilder. This test fails with a fault-tolerant step.

The change you are suggesting fixes the issue, so you are welcome to submit a PR if you want.

@parikshitdutta
Copy link
Contributor

parikshitdutta commented Apr 26, 2021

Hi @benas, please review submitted PR #3897, I will look forward to your feedback.

@fmbenhassine
Copy link
Contributor

Resolved with #3897 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: backport-to-4.2.x Issues that will be back-ported to the 4.2.x line in: core type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants