Description
David Zeigler opened BATCH-1927 and commented
In JpaPagingItemReader, a new transaction is started in the doReadPage method. If an exception is thrown between starting the transaction and committing the transaction, the record is skipped. Then when the next record is processed, tx.begin() will throw an exception because the EntityManager's transaction is active.
One way to reproduce this is by adding an invalid parameter name to queryParameters (one that is not mapped in the queryString). query.setParameter will throw an IllegalArgumentException resulting in the first record being skipped. The next time doReadPage is invoked, the transaction is still active since the tx.commit() was bypassed and there was no tx.rollback(). tx.begin() will throw an IllegalArgumentException because the transaction is already active.
When an exception is thrown prior to tx.commit(), the transaction should be rolled back.
Affects: 2.1.9
2 votes, 3 watchers