curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Makarenko (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CURATOR-211) Fix InterProcessReadWriteLock#readLockPredicate() index validation issue
Date Wed, 29 Apr 2015 22:34:05 GMT
Alexander Makarenko created CURATOR-211:
-------------------------------------------

             Summary: 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
             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 G 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)

Mime
View raw message