Issue Details (XML | Word | Printable)

Key: LUCENE-1233
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Michael McCandless
Reporter: Michael McCandless
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

Fix Document.getFieldables and others to never return null

Created: 14/Mar/08 10:49 AM   Updated: 01/Dec/08 09:18 AM
Return to search
Component/s: Index
Affects Version/s: 2.1, 2.2, 2.3, 2.3.1
Fix Version/s: 2.4

Time Tracking:
Not Specified

Lucene Fields: New
Resolution Date: 14/Mar/08 11:07 AM


 Description  « Hide
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



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Michael McCandless added a comment - 14/Mar/08 11:07 AM
Thanks Stefan!

Michael McCandless made changes - 14/Mar/08 11:07 AM
Field Original Value New Value
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Repository Revision Date User Message
ASF #637053 Fri Mar 14 11:08:28 UTC 2008 mikemccand LUCENE-1233: return empty array instead of null for certain get*s methods in Document
Files Changed
MODIFY /lucene/java/trunk/src/java/org/apache/lucene/document/Document.java
MODIFY /lucene/java/trunk/CHANGES.txt

Repository Revision Date User Message
ASF #637844 Mon Mar 17 11:31:46 UTC 2008 mikemccand LUCENE-1233: correct javadocs
Files Changed
MODIFY /lucene/java/trunk/src/java/org/apache/lucene/document/Document.java

Michael McCandless made changes - 11/Oct/08 12:49 PM
Status Resolved [ 5 ] Closed [ 6 ]
Nadav Har'El added a comment - 01/Dec/08 09:18 AM
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.