You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/04/30 00:40:06 UTC

[jira] [Commented] (CURATOR-211) Fix InterProcessReadWriteLock#readLockPredicate() index validation issue

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

ASF GitHub Bot commented on CURATOR-211:
----------------------------------------

GitHub user estliberitas opened a pull request:

    https://github.com/apache/curator/pull/75

    CURATOR-211 - Fix readLockPredicate() index validation issue

    Fixing bug described in https://issues.apache.org/jira/browse/CURATOR-211.
    
    In case if `ourIndex` is never assigned it will equal to `-1` which will result in throwing exception by `StandardLockInternalsDriver.validateOurIndex()`.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/estliberitas/curator CURATOR-211

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/curator/pull/75.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #75
    
----
commit fc11514987e0ad25046fa384672c6f16408b736b
Author: Alexander Makarenko <es...@gmail.com>
Date:   2015-04-29T22:37:35Z

    CURATOR-211 - Fix readLockPredicate() index validation issue

----


> Fix InterProcessReadWriteLock#readLockPredicate() index validation issue
> ------------------------------------------------------------------------
>
>                 Key: CURATOR-211
>                 URL: https://issues.apache.org/jira/browse/CURATOR-211
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Recipes
>    Affects Versions: awaiting-response
>         Environment: All platforms
>            Reporter: Alexander Makarenko
>              Labels: easyfix, patch
>             Fix For: awaiting-response
>
>
> Hello, guys! I noticed a small bug in {{InterProcessReadWriteLock#readLockPredicate()}} method:
> {code:title=InterProcessReadWriteLock.java, lines 196-211|borderStyle=solid}
> int         ourIndex = Integer.MAX_VALUE;
> for ( String node : children )
> {
>     if ( node.contains(WRITE_LOCK_NAME) )
>     {
>         firstWriteIndex = Math.min(index, firstWriteIndex);
>     }
>     else if ( node.startsWith(sequenceNodeName) )
>     {
>         ourIndex = index;
>         break;
>     }
>     ++index;
> }
> StandardLockInternalsDriver.validateOurIndex(sequenceNodeName, ourIndex);
> {code}
> In case if {{sequenceNodeName}} is not in {{children}} list, {{StandardLockInternalsDriver.validateOurIndex()}} won't throw exception, because {{ourIndex}} in this case equals to {{Integer.MAX_VALUE}}.
> I'm creating pull request on Github to fix this issue.
> I know it's a very rare case, but why not fix it anyways?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)