Skip to content

Commit

Permalink
java.lang.ArrayIndexOutOfBoundsException when indexing a doc, closes e…
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed Jul 6, 2011
1 parent 2d6aa6e commit 4e3d8a8
Showing 1 changed file with 12 additions and 3 deletions.
Expand Up @@ -19,7 +19,11 @@

package org.elasticsearch.index.engine.robin;

import org.apache.lucene.index.*;
import org.apache.lucene.index.ExtendedIndexSearcher;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.util.UnicodeUtil;
import org.elasticsearch.ElasticSearchException;
Expand Down Expand Up @@ -581,7 +585,7 @@ private void innerDelete(Delete delete, IndexWriter writer) throws IOException {

@Override public Searcher searcher() throws EngineException {
AcquirableResource<ReaderSearcherHolder> holder;
for (; ;) {
for (; ; ) {
holder = this.nrtResource;
if (holder.acquire()) {
break;
Expand Down Expand Up @@ -945,7 +949,12 @@ private void innerClose() {
}

private Object dirtyLock(Term uid) {
return dirtyLocks[Math.abs(uid.hashCode()) % dirtyLocks.length];
int hash = uid.text().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 long loadCurrentVersionFromIndex(Term uid) {
Expand Down

0 comments on commit 4e3d8a8

Please sign in to comment.