diff --git a/src/java/org/apache/lucene/document/Document.java b/src/java/org/apache/lucene/document/Document.java index 1e8c447f0c7..f72d8a77836 100644 --- a/src/java/org/apache/lucene/document/Document.java +++ b/src/java/org/apache/lucene/document/Document.java @@ -153,14 +153,11 @@ public final class Document implements java.io.Serializable { } } int fieldCount = tempFieldList.size(); - if (fieldCount == 0) + if (fieldCount == 0) { return null; + } else { - Field[] fields = new Field[fieldCount]; - for (int i = 0; i < fieldCount; i++) { - fields[i] = (Field) tempFieldList.get(i); - } - return fields; + return (Field[])tempFieldList.toArray(new Field[] {}); } }