You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Dominique Pfister (JIRA)" <ji...@apache.org> on 2010/11/10 18:47:14 UTC
[jira] Created: (JCR-2809) Lock expires almost immediately
Lock expires almost immediately
-------------------------------
Key: JCR-2809
URL: https://issues.apache.org/jira/browse/JCR-2809
Project: Jackrabbit Content Repository
Issue Type: Bug
Components: locks
Affects Versions: 2.1.2
Reporter: Dominique Pfister
When a timeoutHint other than Long.MAX_VALUE is given to the javax.jcr.lock.LockManager API:
lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
a timeoutTime in seconds will be computed as follows (o.a.j.core.lock.LockInfo#updateTimeoutTime):
long now = (System.currentTimeMillis() + 999) / 1000; // round up
this.timeoutTime = now + timeoutHint;
the TimeoutHandler in o.a.j.core.lock.LockManagerImpl running every second will then check whether the timeout has expired (o.a.j.core.lock.LockInfo#isExpired):
public boolean isExpired() {
return timeoutTime != Long.MAX_VALUE
&& timeoutTime * 1000 > System.currentTimeMillis();
}
Obviously, the latter condition is true from the very beginning. Replacing '>' with '<' or '<=' should do the trick.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (JCR-2809) Lock expires almost immediately
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-2809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12930956#action_12930956 ]
Felix Meschberger commented on JCR-2809:
----------------------------------------
And why not keep the timeout as ms internally to prevent the repeated multiplication by 1000 ?
> Lock expires almost immediately
> -------------------------------
>
> Key: JCR-2809
> URL: https://issues.apache.org/jira/browse/JCR-2809
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: locks
> Affects Versions: 2.1.2
> Reporter: Dominique Pfister
>
> When a timeoutHint other than Long.MAX_VALUE is given to the javax.jcr.lock.LockManager API:
> lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
> a timeoutTime in seconds will be computed as follows (o.a.j.core.lock.LockInfo#updateTimeoutTime):
> long now = (System.currentTimeMillis() + 999) / 1000; // round up
> this.timeoutTime = now + timeoutHint;
> the TimeoutHandler in o.a.j.core.lock.LockManagerImpl running every second will then check whether the timeout has expired (o.a.j.core.lock.LockInfo#isExpired):
> public boolean isExpired() {
> return timeoutTime != Long.MAX_VALUE
> && timeoutTime * 1000 > System.currentTimeMillis();
> }
> Obviously, the latter condition is true from the very beginning. Replacing '>' with '<' or '<=' should do the trick.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (JCR-2809) Lock expires almost immediately
Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-2809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12930980#action_12930980 ]
Thomas Mueller commented on JCR-2809:
-------------------------------------
There is one more bug when using XA: the timeout time (when will it expire since 1970) is used as the timeout hint (number of seconds until it expires). But anyway the timeout was ignored when using XA.
> Lock expires almost immediately
> -------------------------------
>
> Key: JCR-2809
> URL: https://issues.apache.org/jira/browse/JCR-2809
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: locks
> Affects Versions: 2.1.2
> Reporter: Dominique Pfister
> Assignee: Thomas Mueller
>
> When a timeoutHint other than Long.MAX_VALUE is given to the javax.jcr.lock.LockManager API:
> lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
> a timeoutTime in seconds will be computed as follows (o.a.j.core.lock.LockInfo#updateTimeoutTime):
> long now = (System.currentTimeMillis() + 999) / 1000; // round up
> this.timeoutTime = now + timeoutHint;
> the TimeoutHandler in o.a.j.core.lock.LockManagerImpl running every second will then check whether the timeout has expired (o.a.j.core.lock.LockInfo#isExpired):
> public boolean isExpired() {
> return timeoutTime != Long.MAX_VALUE
> && timeoutTime * 1000 > System.currentTimeMillis();
> }
> Obviously, the latter condition is true from the very beginning. Replacing '>' with '<' or '<=' should do the trick.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (JCR-2809) Lock expires almost immediately
Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-2809?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Mueller reassigned JCR-2809:
-----------------------------------
Assignee: Thomas Mueller
> Lock expires almost immediately
> -------------------------------
>
> Key: JCR-2809
> URL: https://issues.apache.org/jira/browse/JCR-2809
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: locks
> Affects Versions: 2.1.2
> Reporter: Dominique Pfister
> Assignee: Thomas Mueller
>
> When a timeoutHint other than Long.MAX_VALUE is given to the javax.jcr.lock.LockManager API:
> lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
> a timeoutTime in seconds will be computed as follows (o.a.j.core.lock.LockInfo#updateTimeoutTime):
> long now = (System.currentTimeMillis() + 999) / 1000; // round up
> this.timeoutTime = now + timeoutHint;
> the TimeoutHandler in o.a.j.core.lock.LockManagerImpl running every second will then check whether the timeout has expired (o.a.j.core.lock.LockInfo#isExpired):
> public boolean isExpired() {
> return timeoutTime != Long.MAX_VALUE
> && timeoutTime * 1000 > System.currentTimeMillis();
> }
> Obviously, the latter condition is true from the very beginning. Replacing '>' with '<' or '<=' should do the trick.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (JCR-2809) Lock expires almost immediately
Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-2809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12930968#action_12930968 ]
Thomas Mueller commented on JCR-2809:
-------------------------------------
I agree with Felix, repeated multiplication by 1000 could be avoided.
There are more bugs it seems:
- there is a space missing in the toString() representation
- the lock timeout is ignored when using XA - is this on purpose?
> Lock expires almost immediately
> -------------------------------
>
> Key: JCR-2809
> URL: https://issues.apache.org/jira/browse/JCR-2809
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: locks
> Affects Versions: 2.1.2
> Reporter: Dominique Pfister
> Assignee: Thomas Mueller
>
> When a timeoutHint other than Long.MAX_VALUE is given to the javax.jcr.lock.LockManager API:
> lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
> a timeoutTime in seconds will be computed as follows (o.a.j.core.lock.LockInfo#updateTimeoutTime):
> long now = (System.currentTimeMillis() + 999) / 1000; // round up
> this.timeoutTime = now + timeoutHint;
> the TimeoutHandler in o.a.j.core.lock.LockManagerImpl running every second will then check whether the timeout has expired (o.a.j.core.lock.LockInfo#isExpired):
> public boolean isExpired() {
> return timeoutTime != Long.MAX_VALUE
> && timeoutTime * 1000 > System.currentTimeMillis();
> }
> Obviously, the latter condition is true from the very beginning. Replacing '>' with '<' or '<=' should do the trick.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (JCR-2809) Lock expires almost immediately
Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-2809?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Mueller resolved JCR-2809.
---------------------------------
Resolution: Fixed
Fix Version/s: 2.2.0
Fixed in the trunk
> Lock expires almost immediately
> -------------------------------
>
> Key: JCR-2809
> URL: https://issues.apache.org/jira/browse/JCR-2809
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: locks
> Affects Versions: 2.1.2
> Reporter: Dominique Pfister
> Assignee: Thomas Mueller
> Fix For: 2.2.0
>
> Attachments: jcr-2809-lockTimeout.patch
>
>
> When a timeoutHint other than Long.MAX_VALUE is given to the javax.jcr.lock.LockManager API:
> lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
> a timeoutTime in seconds will be computed as follows (o.a.j.core.lock.LockInfo#updateTimeoutTime):
> long now = (System.currentTimeMillis() + 999) / 1000; // round up
> this.timeoutTime = now + timeoutHint;
> the TimeoutHandler in o.a.j.core.lock.LockManagerImpl running every second will then check whether the timeout has expired (o.a.j.core.lock.LockInfo#isExpired):
> public boolean isExpired() {
> return timeoutTime != Long.MAX_VALUE
> && timeoutTime * 1000 > System.currentTimeMillis();
> }
> Obviously, the latter condition is true from the very beginning. Replacing '>' with '<' or '<=' should do the trick.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (JCR-2809) Lock expires almost immediately
Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-2809?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Mueller updated JCR-2809:
--------------------------------
Attachment: jcr-2809-lockTimeout.patch
Proposed patch
> Lock expires almost immediately
> -------------------------------
>
> Key: JCR-2809
> URL: https://issues.apache.org/jira/browse/JCR-2809
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: locks
> Affects Versions: 2.1.2
> Reporter: Dominique Pfister
> Assignee: Thomas Mueller
> Attachments: jcr-2809-lockTimeout.patch
>
>
> When a timeoutHint other than Long.MAX_VALUE is given to the javax.jcr.lock.LockManager API:
> lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
> a timeoutTime in seconds will be computed as follows (o.a.j.core.lock.LockInfo#updateTimeoutTime):
> long now = (System.currentTimeMillis() + 999) / 1000; // round up
> this.timeoutTime = now + timeoutHint;
> the TimeoutHandler in o.a.j.core.lock.LockManagerImpl running every second will then check whether the timeout has expired (o.a.j.core.lock.LockInfo#isExpired):
> public boolean isExpired() {
> return timeoutTime != Long.MAX_VALUE
> && timeoutTime * 1000 > System.currentTimeMillis();
> }
> Obviously, the latter condition is true from the very beginning. Replacing '>' with '<' or '<=' should do the trick.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (JCR-2809) Lock expires almost immediately
Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-2809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12930982#action_12930982 ]
Thomas Mueller commented on JCR-2809:
-------------------------------------
The existing ConcurrentLocking* tests are not included in TestAll. I don't know the reason, it looks like a bug (why having tests if they are not used). I will add them unless somebody objects.
> Lock expires almost immediately
> -------------------------------
>
> Key: JCR-2809
> URL: https://issues.apache.org/jira/browse/JCR-2809
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: locks
> Affects Versions: 2.1.2
> Reporter: Dominique Pfister
> Assignee: Thomas Mueller
>
> When a timeoutHint other than Long.MAX_VALUE is given to the javax.jcr.lock.LockManager API:
> lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
> a timeoutTime in seconds will be computed as follows (o.a.j.core.lock.LockInfo#updateTimeoutTime):
> long now = (System.currentTimeMillis() + 999) / 1000; // round up
> this.timeoutTime = now + timeoutHint;
> the TimeoutHandler in o.a.j.core.lock.LockManagerImpl running every second will then check whether the timeout has expired (o.a.j.core.lock.LockInfo#isExpired):
> public boolean isExpired() {
> return timeoutTime != Long.MAX_VALUE
> && timeoutTime * 1000 > System.currentTimeMillis();
> }
> Obviously, the latter condition is true from the very beginning. Replacing '>' with '<' or '<=' should do the trick.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (JCR-2809) Lock expires almost immediately
Posted by "Tobias Bocanegra (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-2809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12930841#action_12930841 ]
Tobias Bocanegra commented on JCR-2809:
---------------------------------------
or swapping the expressions for better understanding:
public boolean isExpired() {
return timeoutTime != Long.MAX_VALUE
&& System.currentTimeMillis() > timeoutTime * 1000;
}
> Lock expires almost immediately
> -------------------------------
>
> Key: JCR-2809
> URL: https://issues.apache.org/jira/browse/JCR-2809
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: locks
> Affects Versions: 2.1.2
> Reporter: Dominique Pfister
>
> When a timeoutHint other than Long.MAX_VALUE is given to the javax.jcr.lock.LockManager API:
> lock(String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo)
> a timeoutTime in seconds will be computed as follows (o.a.j.core.lock.LockInfo#updateTimeoutTime):
> long now = (System.currentTimeMillis() + 999) / 1000; // round up
> this.timeoutTime = now + timeoutHint;
> the TimeoutHandler in o.a.j.core.lock.LockManagerImpl running every second will then check whether the timeout has expired (o.a.j.core.lock.LockInfo#isExpired):
> public boolean isExpired() {
> return timeoutTime != Long.MAX_VALUE
> && timeoutTime * 1000 > System.currentTimeMillis();
> }
> Obviously, the latter condition is true from the very beginning. Replacing '>' with '<' or '<=' should do the trick.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.