Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-1639

Locking: lock name with negative hashCode() throws out of bound exception

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 3.3.2, 3.4
    • None
    • None

    Description

      [Steve Luebbe]

      Based on the code in the org.jgroups.protocols.Locking it tries to calculate an index based on the lock name (code in next 2 lines):

          protected Lock _getLock(String lock_name) {
              int index=lock_name != null? lock_name.hashCode() % locks.length : 0;
              return locks[index];
          }
      

      When debugging I can see that:

      lock_name = dpa_project
      lock_name.hashCode() = -1316662737
      locks.length = 10

      SOLUTION: use Math.abs() on the hash code

      Attachments

        Issue Links

          Activity

            People

              rhn-engineering-bban Bela Ban
              rhn-engineering-bban Bela Ban
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: