Lucene - Core
  1. Lucene - Core
  2. LUCENE-1686

Remove Unnecessary NULL check in FindSegmentsFile - cleanup

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.9, 3.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      FindSegmentsFile accesses the member "directory" in line 579 while performing a null check in 592. The null check is unnecessary as if directory is null line 579 would throw a NPE.
      I removed the null check and made the member "directory" final. In addition I added a null check in the constructor as If the value is null we should catch it asap.

      1. segments_info.patch
        4 kB
        Simon Willnauer

        Activity

        Hide
        Uwe Schindler added a comment -

        Thanks, I was working on this class some days ago, I will apply this!

        Thanks!

        Show
        Uwe Schindler added a comment - Thanks, I was working on this class some days ago, I will apply this! Thanks!
        Hide
        Uwe Schindler added a comment -

        Comitted revision 784094.

        This was my fault, because I refactored the class and missed to remove this unnecessary check. Before there was also support for java.io.File instead of o.a.l.store.Directory in this class for which this null-check was.
        I removed the initial null check in the ctor, as it is not necessary (this class is internal only and never called with NULL directory).

        Show
        Uwe Schindler added a comment - Comitted revision 784094. This was my fault, because I refactored the class and missed to remove this unnecessary check. Before there was also support for java.io.File instead of o.a.l.store.Directory in this class for which this null-check was. I removed the initial null check in the ctor, as it is not necessary (this class is internal only and never called with NULL directory).

          People

          • Assignee:
            Uwe Schindler
            Reporter:
            Simon Willnauer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development