From 050bfc31b672f63ac3d76c49a7c2fc62833c9ab3 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 7 Mar 2016 11:25:52 +0100 Subject: [PATCH] Don't call IR#leaves() after global field data has been constructed This IR may already be closed and GlobalFieldData is cached and this can cause AlreadyClosedException while checking the assert. --- .../fielddata/plain/ParentChildIndexFieldData.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java index 14d0375ba57..f7b25832283 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java @@ -305,13 +305,15 @@ public class ParentChildIndexFieldData extends AbstractIndexFieldData leaves; private final AtomicParentChildFieldData[] fielddata; - private final IndexReader reader; private final long ramBytesUsed; private final Map ordinalMapPerType; GlobalFieldData(IndexReader reader, AtomicParentChildFieldData[] fielddata, long ramBytesUsed, Map ordinalMapPerType) { - this.reader = reader; + this.coreCacheKey = reader.getCoreCacheKey(); + this.leaves = reader.leaves(); this.ramBytesUsed = ramBytesUsed; this.fielddata = fielddata; this.ordinalMapPerType = ordinalMapPerType; @@ -329,7 +331,7 @@ public class ParentChildIndexFieldData extends AbstractIndexFieldData