[OPENJPA-2986] Let setTimeout(null) clear a query timeout - #169
Open
rzo1 wants to merge 1 commit into
Open
Conversation
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.
cristof
approved these changes
Aug 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Query.setTimeout(null)passed the null straight tosetHint(), which drove it throughFetchConfigurationImpl.setHint()into a reflective call ofsetQueryTimeout(int)and failed with abad-hint-valueIllegalArgumentException. So a timeout set through this API could never be cleared — on queries it did not silently ignore the null, it threw — andgetTimeout()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 notFetchPlan.DEFAULT, which resolves to theOpenJPAConfigurationvalue 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, andStoredProcedureQueryImpldelegates both methods to its query so the two cannot drift apart.EntityManagerImplcarries asetTimeout/getTimeoutpair too, but those implementEntityTransaction— a transaction timeout in seconds — and are left alone here.