Lucene - Core
  1. Lucene - Core
  2. LUCENE-2496

NPE if you open IW with CREATE on an index with no segments file

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.1, 4.0-ALPHA
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      I have a simple test case that hits this NPE:

          [junit] java.lang.NullPointerException
          [junit] 	at java.io.File.<init>(File.java:305)
          [junit] 	at org.apache.lucene.store.NIOFSDirectory.openInput(NIOFSDirectory.java:67)
          [junit] 	at org.apache.lucene.store.FSDirectory.openInput(FSDirectory.java:333)
          [junit] 	at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:213)
          [junit] 	at org.apache.lucene.index.IndexFileDeleter.<init>(IndexFileDeleter.java:218)
          [junit] 	at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:1113)
          [junit] 	at org.apache.lucene.index.TestIndexWriter.testNoSegmentFile(TestIndexWriter.java:4975)
          [junit] 	at org.apache.lucene.util.LuceneTestCase.runBare(LuceneTestCase.java:277)
      

      It happens if you have an aborted index, ie, there are segment files in there (*.frq, *.tis, etc.) but no segments_N file, and then you try to open an IW with CREATE on that index.

      1. LUCENE-2496.patch
        5 kB
        Michael McCandless

        Activity

        Hide
        Michael McCandless added a comment -

        Simple fix – just check if current segments file is null before trying to open it. I was also able to remove "seenIndexFiles" since we can instead use "currentSegmentsFile != null".

        Show
        Michael McCandless added a comment - Simple fix – just check if current segments file is null before trying to open it. I was also able to remove "seenIndexFiles" since we can instead use "currentSegmentsFile != null".
        Hide
        Robert Muir added a comment -

        reopening for possible 2.9.4/3.0.3 backport.

        Show
        Robert Muir added a comment - reopening for possible 2.9.4/3.0.3 backport.
        Hide
        Michael McCandless added a comment -

        OK I believe we don't need to backport this fix (the test case alone does not fail).

        This bug was introduced with LUCENE-2386, which we don't plan to back port.

        Show
        Michael McCandless added a comment - OK I believe we don't need to backport this fix (the test case alone does not fail). This bug was introduced with LUCENE-2386 , which we don't plan to back port.
        Hide
        Grant Ingersoll added a comment -

        Bulk close for 3.1

        Show
        Grant Ingersoll added a comment - Bulk close for 3.1

          People

          • Assignee:
            Michael McCandless
            Reporter:
            Michael McCandless
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development