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/04/30 08:33:16 UTC

[GitHub] sijie commented on a change in pull request #1372: OrderedScheduler#chooseThread(key) handle null key

sijie commented on a change in pull request #1372: OrderedScheduler#chooseThread(key) handle null key
URL: https://github.com/apache/bookkeeper/pull/1372#discussion_r184933277
 
 

 ##########
 File path: bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java
 ##########
 @@ -348,7 +348,11 @@ public ExecutorService chooseThread(Object orderingKey) {
             return threads[0];
         }
 
-        return threads[MathUtils.signSafeMod(orderingKey.hashCode(), threads.length)];
+        if (null == orderingKey) {
+            return threads[rand.nextInt(threads.length)];
+        } else {
+            return threads[MathUtils.signSafeMod(orderingKey.hashCode(), threads.length)];
+        }
 
 Review comment:
   it is for convenience, so in the caller, I don't have to do `if (orderKey != null) chooseThread(orderKey); else chooseThread(..)`. I can have a separate util function to do that, but I feel it is better to do it at the executor level.

----------------------------------------------------------------
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