Skip to content

JpaPagingItemReader invokes tx.begin() on active transactions [BATCH-1927] #1665

Open
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions