Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-1233

Fix Document.getFieldables and others to never return null

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1, 2.2, 2.3, 2.3.1
    • Fix Version/s: 2.4
    • Component/s: core/index
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Document.getFieldables (and other similar methods) returns null if there are no fields matching the name. We can avoid NPE in consumers of this API if instead we return an empty array.

      Spinoff from http://markmail.org/message/g2nzstmce4cnf3zj

        Activity

        Hide
        mikemccand Michael McCandless added a comment -

        Thanks Stefan!

        Show
        mikemccand Michael McCandless added a comment - Thanks Stefan!
        Hide
        nyh Nadav Har'El added a comment -

        Hi, I know this comment is a bit too late, but I thought I'd make it anyway as I assume many people will be switching from Lucene 2.3 to 2.4 soon and may encounter this.

        The issue is that while this API change will indeed simplify life for some writers of new code, it may cause some existing code to break unless fixed.

        For example, I have code which wanted to check whether or not there are any values to this field (e.g., to print a header before looping to show the values), and had the check doc.getFields(name)Unable to render embedded object: File (=null. This check no longer works and needs to be changed to ...length()) not found.=0.

        Show
        nyh Nadav Har'El added a comment - Hi, I know this comment is a bit too late, but I thought I'd make it anyway as I assume many people will be switching from Lucene 2.3 to 2.4 soon and may encounter this. The issue is that while this API change will indeed simplify life for some writers of new code, it may cause some existing code to break unless fixed. For example, I have code which wanted to check whether or not there are any values to this field (e.g., to print a header before looping to show the values), and had the check doc.getFields(name) Unable to render embedded object: File (=null. This check no longer works and needs to be changed to ...length()) not found. =0.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development