From 55237c881fced430b296737e77b996fc519ecc71 Mon Sep 17 00:00:00 2001 From: Daniel Naber Date: Sat, 13 May 2006 23:50:35 +0000 Subject: [PATCH] throw IllegalArgumentException if both field name and value are empty (to avoid a confusing "term out of order" exception later) git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@406168 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 ++++ src/java/org/apache/lucene/document/Field.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 238618130fa..894ea8ad9f3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,6 +13,10 @@ API Changes 2. DisjunctionSumScorer is no longer public. (Paul Elschot via Otis Gospodnetic) + + 3. Creating a Field with both an empty name and an empty value + now throws an IllegalArgumentException + (Daniel Naber) Bug fixes diff --git a/src/java/org/apache/lucene/document/Field.java b/src/java/org/apache/lucene/document/Field.java index 627f56e23ac..dc2c7eb1897 100644 --- a/src/java/org/apache/lucene/document/Field.java +++ b/src/java/org/apache/lucene/document/Field.java @@ -238,6 +238,8 @@ public final class Field implements Serializable { throw new NullPointerException("name cannot be null"); if (value == null) throw new NullPointerException("value cannot be null"); + if (name.length() == 0 && value.length() == 0) + throw new IllegalArgumentException("name and value cannot both be empty"); if (index == Index.NO && store == Store.NO) throw new IllegalArgumentException("it doesn't make sense to have a field that " + "is neither indexed nor stored");