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

lost transactionAttribute when using chaining StepBuilder #3686

Closed
hoyeol opened this issue Mar 27, 2020 · 3 comments
Closed

lost transactionAttribute when using chaining StepBuilder #3686

hoyeol opened this issue Mar 27, 2020 · 3 comments

Comments

@hoyeol
Copy link

hoyeol commented Mar 27, 2020

lost transactionAttribute when using chaining StepBuilder.

  • according to below code, there will be lost "transactionAttribute" already set.
DefaultTransactionAttribute readOnlyTxAttribute = new DefaultTransactionAttribute();
readOnlyTxAttribute.setReadOnly(true);
stepBuilderFactory.get("stepName")
.transactionManager(txManager)
.<InputType, OutputType>chunk(CHUNK_SIZE)
.reader(reader)
.writer(writer)
.transactionAttribute(readOnlyTxAttribute)
.faultTolerant()
.backOffPolicy(backOffPolicy())
.retryLimit(3)
.retry(SomeException.class)
.build();
  • next below code, does not lost transactionAttribute. (just only difference is "where is transactionAttribute method call")
DefaultTransactionAttribute readOnlyTxAttribute = new DefaultTransactionAttribute();
readOnlyTxAttribute.setReadOnly(true);
stepBuilderFactory.get("stepName")
.transactionManager(txManager)
.<InputType, OutputType>chunk(CHUNK_SIZE)
.reader(reader)
.writer(writer)
.faultTolerant()
.backOffPolicy(backOffPolicy())
.retryLimit(3)
.retry(SomeException.class)
.transactionAttribute(readOnlyTxAttribute)
.build();

it seems to broken compatibility between SimpleStepBuilder and FaultTolerantStepBuilder (and both classes extends AbstractTaskletStepBuilder what have transactionAttribute property.)

there transactionAttributes will be missing on method calls. (there methods does not support copying "transactionAttribute")

  • org.springframework.batch.core.step.builder.SimpleStepBuilder.faultTolerant
  • org.springframework.batch.core.step.builder.FaultTolerantStepBuilder constructor
  • org.springframework.batch.core.step.builder.SimpleStepBuilder constructor
  • org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder constructor
  • org.springframework.batch.core.step.builder.StepBuilderHelper constructor
@fmbenhassine fmbenhassine added the status: waiting-for-triage Issues that we did not analyse yet label Mar 30, 2020
@acktsap
Copy link
Contributor

acktsap commented Sep 29, 2021

I can't reproduce it by a syntax error.

Screen Shot 2021-09-30 at 4 47 06

It looks because the transactionAttribute returns AbstractTaskletStepBuilder, not SimpleStepBuilder.

public AbstractTaskletStepBuilder<B> transactionAttribute(TransactionAttribute transactionAttribute) {
this.transactionAttribute = transactionAttribute;
return this;
}

It works when transactionAttribute is after the faultTolerant.

Screen Shot 2021-09-30 at 4 48 33

@acktsap
Copy link
Contributor

acktsap commented Sep 30, 2021

But if #3989 is merged, it should be fixed.

@fmbenhassine
Copy link
Contributor

Resolved with #3989 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants