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

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

XMLWordPrintable

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

      [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

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

                Created:
                Updated:
                Resolved: