From b591e8c5805618c6186fc1607ffad00f44cd1ebe Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Sat, 10 May 2008 08:48:50 +0000 Subject: [PATCH] LUCENE-1282: upgrade an assert to a real check, to work around Sun JRE hotspot bug to prevent index corruption git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@655030 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/lucene/index/SegmentMerger.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/lucene/index/SegmentMerger.java b/src/java/org/apache/lucene/index/SegmentMerger.java index bf3ce9a5c5d..748ff579682 100644 --- a/src/java/org/apache/lucene/index/SegmentMerger.java +++ b/src/java/org/apache/lucene/index/SegmentMerger.java @@ -355,8 +355,15 @@ final class SegmentMerger { fieldsWriter.close(); } - assert 4+docCount*8 == directory.fileLength(segment + "." + IndexFileNames.FIELDS_INDEX_EXTENSION) : - "after mergeFields: fdx size mismatch: " + docCount + " docs vs " + directory.fileLength(segment + "." + IndexFileNames.FIELDS_INDEX_EXTENSION) + " length in bytes of " + segment + "." + IndexFileNames.FIELDS_INDEX_EXTENSION; + final long fdxFileLength = directory.fileLength(segment + "." + IndexFileNames.FIELDS_INDEX_EXTENSION); + + if (4+docCount*8 != fdxFileLength) + // This is most like a bug in Sun JRE 1.6.0_04/_05; + // we detect that the bug has struck, here, and + // throw an exception to prevent the corruption from + // entering the index. See LUCENE-1282 for + // details. + throw new RuntimeException("mergeFields produced an invalid result: docCount is " + docCount + " but fdx file size is " + fdxFileLength + "; now aborting this merge to prevent index corruption"); } else // If we are skipping the doc stores, that means there