From 6f7b462f1dbd139955e10561e09522e0ffa13f3e Mon Sep 17 00:00:00 2001 From: kimchy Date: Wed, 6 Jul 2011 18:57:11 +0300 Subject: [PATCH] java.lang.ArrayIndexOutOfBoundsException when indexing a doc, closes #1094. --- .../org/elasticsearch/index/engine/robin/RobinEngine.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java index 02361e9d45b..20a137421d2 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java @@ -1182,7 +1182,12 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } private Object dirtyLock(String id) { - return dirtyLocks[Math.abs(id.hashCode()) % dirtyLocks.length]; + int hash = id.hashCode(); + // abs returns Integer.MIN_VALUE, so we need to protect against it... + if (hash == Integer.MIN_VALUE) { + hash = 0; + } + return dirtyLocks[Math.abs(hash) % dirtyLocks.length]; } private Object dirtyLock(Term uid) {