[ 
https://issues.apache.org/jira/browse/OPENJPA-2986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18110763#comment-18110763
 ] 

ASF subversion and git services commented on OPENJPA-2986:
----------------------------------------------------------

Commit 360a9e861f9434e7e325badb41157fedea799744 in openjpa's branch 
refs/heads/master from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=360a9e861 ]

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

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

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.

* [OPENJPA-2986] Report the timeout only when one is set on the query

Review feedback: getTimeout() derived null from the effective value being
non positive, so an explicit setTimeout(0) read back as null while a query
that merely inherited a timeout reported one. It now reports null when no
timeout is set on the query itself, and the effective value otherwise.

setTimeout(null) drops the recorded hint instead of re-recording the
inherited value, so a cleared timeout no longer shows up in getHints() and
no longer outranks a later openjpa.FetchPlan.QueryTimeout hint.

Also corrects the javadoc: a null timeout clears the timeout whatever set
it, not only one set through this method, and restores the value the entity
manager carries at that point rather than the one the query was created
with.

> setTimeout(null) cannot clear a previously set query timeout
> ------------------------------------------------------------
>
>                 Key: OPENJPA-2986
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2986
>             Project: OpenJPA
>          Issue Type: Sub-task
>          Components: jpa
>    Affects Versions: 4.2.0
>            Reporter: Maxim Solodovnik
>            Assignee: Richard Zowalla
>            Priority: Major
>             Fix For: 4.2.0
>
>
> Discussion thread: 
> https://github.com/apache/openjpa/pull/144#discussion_r3683006065
> **(low)** `setTimeout(null)` is silently ignored, so once a timeout is set it 
> can never be cleared through this API (and `getTimeout()` keeps returning the 
> stale value). Should null reset the fetch plan's query timeout to its 
> default? 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to