mirror of https://github.com/apache/lucene.git
close DV producers on exception
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1619609 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
75ed12e0c7
commit
999f7ab30d
|
@ -48,11 +48,15 @@ class SegmentDocValuesProducer extends DocValuesProducer {
|
|||
final List<Long> dvGens = new ArrayList<>();
|
||||
|
||||
SegmentDocValuesProducer(SegmentCommitInfo si, Directory dir, FieldInfos fieldInfos, SegmentDocValues segDocValues, DocValuesFormat dvFormat) throws IOException {
|
||||
boolean success = false;
|
||||
try {
|
||||
Version ver = si.info.getVersion();
|
||||
if (ver != null && ver.onOrAfter(Version.LUCENE_4_9_0)) {
|
||||
DocValuesProducer baseProducer = null;
|
||||
for (FieldInfo fi : fieldInfos) {
|
||||
if (!fi.hasDocValues()) continue;
|
||||
if (!fi.hasDocValues()) {
|
||||
continue;
|
||||
}
|
||||
long docValuesGen = fi.getDocValuesGen();
|
||||
if (docValuesGen == -1) {
|
||||
if (baseProducer == null) {
|
||||
|
@ -76,7 +80,9 @@ class SegmentDocValuesProducer extends DocValuesProducer {
|
|||
// we initialize each DocValuesProducer once per gen.
|
||||
Map<Long,List<FieldInfo>> genInfos = new HashMap<>();
|
||||
for (FieldInfo fi : fieldInfos) {
|
||||
if (!fi.hasDocValues()) continue;
|
||||
if (!fi.hasDocValues()) {
|
||||
continue;
|
||||
}
|
||||
List<FieldInfo> genFieldInfos = genInfos.get(fi.getDocValuesGen());
|
||||
if (genFieldInfos == null) {
|
||||
genFieldInfos = new ArrayList<>();
|
||||
|
@ -103,6 +109,16 @@ class SegmentDocValuesProducer extends DocValuesProducer {
|
|||
}
|
||||
}
|
||||
}
|
||||
success = true;
|
||||
} finally {
|
||||
if (success == false) {
|
||||
try {
|
||||
segDocValues.decRef(dvGens);
|
||||
} catch (Throwable t) {
|
||||
// Ignore so we keep throwing first exception
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue