You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/08/21 00:13:31 UTC

[GitHub] reddycharan commented on a change in pull request #1616: Index for lockarray should be non-negative

reddycharan commented on a change in pull request #1616: Index for lockarray should be non-negative
URL: https://github.com/apache/bookkeeper/pull/1616#discussion_r211445542
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogManagerForEntryLogPerLedger.java
 ##########
 @@ -93,7 +93,7 @@ BufferedLogChannel getLogChannel() {
         private BufferedLogChannelWithDirInfo entryLogWithDirInfo;
 
         private EntryLogAndLockTuple(long ledgerId) {
-            int lockIndex = Long.hashCode(ledgerId) % lockArrayPool.length();
+            int lockIndex = Math.abs(Long.hashCode(ledgerId) % lockArrayPool.length());
 
 Review comment:
   https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17.3
   
   in java for modulo (remainder) operation both right and left operands can be negative.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services