beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lc...@apache.org
Subject [2/4] incubator-beam git commit: Uses ThreadLocalRandom.current to generate a random hashCode
Date Thu, 07 Jul 2016 13:46:31 GMT
Uses ThreadLocalRandom.current to generate a random hashCode


Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/9df033cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/9df033cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/9df033cb

Branch: refs/heads/master
Commit: 9df033cb0921836b25ff685c55fc1a93fff4a36f
Parents: 708244b
Author: Lucas Amorim <lucasamorim@Lucass-MBP.hitronhub.home>
Authored: Wed Jul 6 23:01:55 2016 -0700
Committer: Luke Cwik <lcwik@visitor-lcwik.wat.corp.google.com>
Committed: Thu Jul 7 09:07:15 2016 -0400

----------------------------------------------------------------------
 .../org/apache/beam/sdk/options/ProxyInvocationHandler.java    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/9df033cb/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java
index 0c10c2f..cb69979 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java
@@ -66,10 +66,10 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Random;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
+import java.util.concurrent.ThreadLocalRandom;
 
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.ThreadSafe;
@@ -94,8 +94,8 @@ class ProxyInvocationHandler implements InvocationHandler, HasDisplayData
{
    * No two instances of this class are considered equivalent hence we generate a random
hash code
    * between 0 and {@link Integer#MAX_VALUE}.
    */
-  private final int hashCode = (RANDOM.nextInt() * Integer.MAX_VALUE);
-  private static final Random RANDOM = new Random();
+  private final int hashCode =  ThreadLocalRandom.current().nextInt(
+          Integer.MIN_VALUE, Integer.MAX_VALUE);
   private final Set<Class<? extends PipelineOptions>> knownInterfaces;
   private final ClassToInstanceMap<PipelineOptions> interfaceToProxyCache;
   private final Map<String, BoundValue> options;


Mime
View raw message