Skip to content

[OPENJPA-2986] Let setTimeout(null) clear a query timeout - #169

Open
rzo1 wants to merge 1 commit into
masterfrom
OPENJPA-2986
Open

[OPENJPA-2986] Let setTimeout(null) clear a query timeout#169
rzo1 wants to merge 1 commit into
masterfrom
OPENJPA-2986

Conversation

@rzo1

@rzo1 rzo1 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Query.setTimeout(null) passed the null straight to setHint(), which drove it through FetchConfigurationImpl.setHint() into a reflective call of setQueryTimeout(int) and failed with a bad-hint-value IllegalArgumentException. So a timeout set through this API could never be cleared — on queries it did not silently ignore the null, it threw — and getTimeout() kept reporting the stale value.

A null timeout now restores the timeout the query inherits from its entity manager, which is what the query would have used had setTimeout() never been called. Deliberately not FetchPlan.DEFAULT, which resolves to the OpenJPAConfiguration value and would discard an entity-manager-scoped timeout the caller never set here.

getTimeout() reports the effective fetch plan value rather than the recorded hint, so it cannot disagree with what the query will actually use, and StoredProcedureQueryImpl delegates both methods to its query so the two cannot drift apart.

EntityManagerImpl carries a setTimeout/getTimeout pair too, but those implement EntityTransaction — a transaction timeout in seconds — and are left alone here.

Query.setTimeout(null) passed the null straight to setHint(), which drove
it through FetchConfigurationImpl.setHint() into a reflective call of
setQueryTimeout(int) and failed with a bad-hint-value
IllegalArgumentException. A timeout set through this API could therefore
never be cleared, and getTimeout() kept reporting the stale value.

A null timeout now restores the timeout the query inherits from its entity
manager, which is what the query would have used had setTimeout() never
been called. Deliberately not the value of the configuration, which would
discard an entity manager scoped timeout the caller never set here.

getTimeout() reports the effective fetch plan value rather than the
recorded hint, so it cannot disagree with what the query will actually
use, and StoredProcedureQueryImpl delegates both methods to its query so
the two cannot drift apart.

EntityManagerImpl carries a setTimeout/getTimeout pair too, but those
implement EntityTransaction, a transaction timeout in seconds, and are left
alone here.
@rzo1 rzo1 self-assigned this Aug 29, 2026
@rzo1
rzo1 requested review from cristof and solomax August 29, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants