[jboss-jira] [JBoss JIRA] (JGRP-1639) Locking: lock name with negative hashCode() throws out of bound exception

Bela Ban (JIRA) jira-events at lists.jboss.org
Mon Jun 3 10:48:54 EDT 2013


Bela Ban created JGRP-1639:
------------------------------

             Summary: Locking: lock name with negative hashCode() throws out of bound exception
                 Key: JGRP-1639
                 URL: https://issues.jboss.org/browse/JGRP-1639
             Project: JGroups
          Issue Type: Bug
            Reporter: Bela Ban
            Assignee: Bela Ban
             Fix For: 3.2.10, 3.4


[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):
{code}
    protected Lock _getLock(String lock_name) {
        int index=lock_name != null? lock_name.hashCode() % locks.length : 0;
        return locks[index];
    }
{code}
 

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

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list