From aa26b716a88006a45f520394aab841875d26b3e7 Mon Sep 17 00:00:00 2001 From: charles Date: Wed, 27 Nov 2013 16:34:51 +0800 Subject: [PATCH] Update ConnectionSet.java if hashCode equals Integer.MIN_VALUE, may cause NPE . --- src/core/org/apache/hadoop/ipc/ConnectionSet.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/org/apache/hadoop/ipc/ConnectionSet.java b/src/core/org/apache/hadoop/ipc/ConnectionSet.java index 6bfae917..be2a1d1c 100644 --- a/src/core/org/apache/hadoop/ipc/ConnectionSet.java +++ b/src/core/org/apache/hadoop/ipc/ConnectionSet.java @@ -125,7 +125,12 @@ int getBucketIndexFromConnection(Connection c) { if (c == null || (connString = c.toString()) == null) { return 0; } - int hashCode = Math.abs(connString.hashCode()); + int hashCode = connString.hashCode(); + if (hashCode == Integer.MIN_VALUE) { + hashCode = Integer.MAX_VALUE; + } else { + hashCode = Math.abs(hashCode); + } return hashCode % numBuckets; }