WASdev / standards.jsr352.jbatch

Home of 'jbatch', a compatible implementation of the Jakarta Batch specification (and the former Reference Implementation for the JSR 352, Batch Applications for the Java Platform specification).
Other
21 stars 18 forks source link

ChunkListener.onError() should not be called in case of exceptions outside of chunks #20

Closed mariok closed 9 years ago

mariok commented 9 years ago

As we have some integration-tests running on different application-servers, we discovered some differences in the behavior of the jbatch-implementations concerning listeners in case of exceptions:

If an exception occurs inside the ItemReader/ItemWriter open() or close() methods, then in case of JBeret, the ChunkListener.onError() method is not called, while the JBatch RI included in GlassFish 4 as well as Apache BatchEE do call the method.

This issue has already been discussed in the JBeret issue-tracker:

https://github.com/jberet/jsr352/issues/25

Cheng Fang summarizes it as follows: "A chunk-type step consists of multiple chunks, and ChunkListener is for these smaller chunks, not for the entire step. When ItemReader.open() is called at the beginning of the step, we haven't come to any chunk yet, why should the ChunkListener be called?"

I agree with him, that according to the spec, the ChunkListener should not be called in case of exceptions inside the open() and close() methods. So I think the BatchEE implementation should be adjusted here. Please refer to the JBeret issue linked above for more details.

Related to this issue, I have opened a discussion on the jbatch public mailing list for enhancing the error-handling with listeners:

https://java.net/projects/jbatch/lists/public/archive/2014-12/message/3

Please see also: https://issues.apache.org/jira/browse/BATCHEE-56

scottkurz commented 9 years ago

I don't want to change the behavior unless we decide to change the spec in the next release.

I opened up a spec issue to consider this: https://java.net/bugzilla/show_bug.cgi?id=6587

and so am closing this issue.