From a3d8022dc50e9d33f40177b1ab95c5f2d4fc78ab Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Thu, 24 Jul 2014 18:59:44 +0200 Subject: [PATCH] Fielddata: Fix thread safety issue with field data on the `_index` field. --- .../fielddata/plain/IndexIndexFieldData.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/fielddata/plain/IndexIndexFieldData.java b/src/main/java/org/elasticsearch/index/fielddata/plain/IndexIndexFieldData.java index f2531835ac8..3850d7920c5 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/plain/IndexIndexFieldData.java +++ b/src/main/java/org/elasticsearch/index/fielddata/plain/IndexIndexFieldData.java @@ -43,9 +43,19 @@ public class IndexIndexFieldData extends AbstractIndexOrdinalsFieldData { private static class IndexAtomicFieldData extends AbstractAtomicOrdinalsFieldData { - private final RandomAccessOrds values; + private final String index; IndexAtomicFieldData(String index) { + this.index = index; + } + + @Override + public long ramBytesUsed() { + return 0; + } + + @Override + public RandomAccessOrds getOrdinalsValues() { final BytesRef term = new BytesRef(index); final SortedDocValues sortedValues = new SortedDocValues() { @@ -64,17 +74,7 @@ public class IndexIndexFieldData extends AbstractIndexOrdinalsFieldData { return 0; } }; - values = (RandomAccessOrds) DocValues.singleton(sortedValues); - } - - @Override - public long ramBytesUsed() { - return 0; - } - - @Override - public RandomAccessOrds getOrdinalsValues() { - return values; + return (RandomAccessOrds) DocValues.singleton(sortedValues); } @Override