Uploaded image for project: 'Apache Curator'
  1. Apache Curator
  2. CURATOR-211

Fix InterProcessReadWriteLock#readLockPredicate() index validation issue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • awaiting-response
    • 2.8.0
    • Recipes
    • All platforms

    Description

      Hello, guys! I noticed a small bug in InterProcessReadWriteLock#readLockPredicate() method:

      InterProcessReadWriteLock.java, lines 196-211
      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);
      

      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?

      Attachments

        Issue Links

          Activity

            People

              randgalt Jordan Zimmerman
              estliberitas Alexander Makarenko
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: