You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect the last listener to register the ItemListener correctly, using the listener(ItemReadLiistener listener) method in the SimpleStepBuilder class, but the listener(Object listener) method in the AbstractTaskletStepBuilder gets invoked instead.
The reason for this is that the listener(StepExecutionListener listener) method resides in the StepBuilderHelper class, and that method returns an AbstractTaskletStepBuilder, and not a SimpleStepBuilder, what it should really return. In other words, the inheritance of SimpleStepBuilder > AbstractTaskletStepBuilder > StepBuilderHelper is messed up.
To illustrate, consider the following tweaked example...
Here, the first listener(itemReadListener) gets invoked in the AbstractTaskletStepBuilder class (which does nothing for an ItemReadListener) and the second listener(itemReadListener) gets invoked in the SimpleStepBuilder class (as it should).
I've resolved this issue myself by annotating the method on my StepExecutionListener with @BeforeStep and @AfterStep, and removing the implements StepExecution from the class declaration.
I've done thesame for my ItemReaderListener and ItemWriterListener and annotated the method with @OnReadError and @OnWriteError. They're no longet implementations of ItemReadListener and ItemWriteListener.
I've only found out I could do this by inspecting the source code though. I hadn't seen it in the docs.
I still believe this is a bug though. I think the methods in the StepBuilderHelper should return a SimpleStepBuilder and not an AbstractTaskletStepBuilder
fmbenhassine
changed the title
ItemReadListener not being correctly registered after adding a StepExecutionListener [BATCH-2841]
ItemReadListener not being correctly registered after adding a StepExecutionListener
Jul 19, 2022
Benne Otten opened BATCH-2841 and commented
I've stumbled upon this bug and it gave me quite a headache.
Consider the following Step configuration
I would expect the last listener to register the ItemListener correctly, using the listener(ItemReadLiistener listener) method in the SimpleStepBuilder class, but the listener(Object listener) method in the AbstractTaskletStepBuilder gets invoked instead.
The reason for this is that the listener(StepExecutionListener listener) method resides in the StepBuilderHelper class, and that method returns an AbstractTaskletStepBuilder, and not a SimpleStepBuilder, what it should really return. In other words, the inheritance of SimpleStepBuilder > AbstractTaskletStepBuilder > StepBuilderHelper is messed up.
To illustrate, consider the following tweaked example...
Here, the first listener(itemReadListener) gets invoked in the AbstractTaskletStepBuilder class (which does nothing for an ItemReadListener) and the second listener(itemReadListener) gets invoked in the SimpleStepBuilder class (as it should).
No further details from BATCH-2841
The text was updated successfully, but these errors were encountered: