spring-projects / spring-projects/spring-batch

Using chunk-completion-policy gives an error [BATCH-2670]

Open
#934 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
Dominant language
Java
Stars
3k
Forks
2.5k
Avg merge
6d 53m
Merged PRs (30d)
3

Description

Azat opened BATCH-2670 and commented

We have the following tasklet:

<tasklet>
	<chunk reader="detail-reader"
		   writer="detail-writer"
		   commit-interval="0"
		   chunk-completion-policy="singleChunkCompletionPolicy"/>
</tasklet>

And it works fine. But the spring documentation says to use either this or chunk-completion-policy but not both.
So now if I remove commit-interval="0" it gives an error:

    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1634)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
    ... 60 more
Caused by: java.lang.IllegalStateException: You must specify either a chunkCompletionPolicy or a commitInterval but not both.
    at org.springframework.util.Assert.state(Assert.java:70)
    at org.springframework.batch.core.step.builder.SimpleStepBuilder.chunk(SimpleStepBuilder.java:190)
    at org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean.createFaultTolerantStep(StepParserStepFactoryBean.java:353)
    at org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean.getObject(StepParserStepFactoryBean.java:274)
    at org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean.getObject(StepParserStepFactoryBean.java:113)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
    ... 65 more```

Expected result:
It should let us to specify chunk-completion-policy without setting commit-interval to zero.


Affects: 3.0.7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the XML configuration using chunk-completion-policy without commit-interval, then start at StepParserStepFactoryBean.createFaultTolerantStep and follow the call into SimpleStepBuilder.chunk. Compare how the two chunk attributes are passed to the builder. Done means the configuration is accepted with the completion policy alone and the reported IllegalStateException no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.