lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From busc...@apache.org
Subject svn commit: r558917 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/index/FieldInfos.java
Date Tue, 24 Jul 2007 03:05:24 GMT
Author: buschmi
Date: Mon Jul 23 20:05:21 2007
New Revision: 558917

URL: http://svn.apache.org/viewvc?view=rev&rev=558917
Log:
LUCENE-939: Check explicitly for boundary conditions in FieldInfos.

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?view=diff&rev=558917&r1=558916&r2=558917
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Mon Jul 23 20:05:21 2007
@@ -1,4 +1,4 @@
-Lucene Change Log
+Lucene Change Log
 
 $Id$
 
@@ -79,6 +79,9 @@
  5. LUCENE-963: Add setters to Field to allow for re-using a single
     Field instance during indexing.  This is a sizable performance
     gain, especially for small documents.  (Mike McCandless)
+
+ 6. LUCENE-939: Check explicitly for boundary conditions in FieldInfos
+    and don't rely on exceptions. (Michael Busch)
 
 Documentation
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java?view=diff&rev=558917&r1=558916&r2=558917
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java Mon Jul 23 20:05:21
2007
@@ -230,15 +230,8 @@
   }
 
   public int fieldNumber(String fieldName) {
-    try {
-      FieldInfo fi = fieldInfo(fieldName);
-      if (fi != null)
-        return fi.number;
-    }
-    catch (IndexOutOfBoundsException ioobe) {
-      return -1;
-    }
-    return -1;
+    FieldInfo fi = fieldInfo(fieldName);
+    return (fi != null) ? fi.number : -1;
   }
 
   public FieldInfo fieldInfo(String fieldName) {
@@ -253,12 +246,8 @@
    * with the given number doesn't exist.
    */  
   public String fieldName(int fieldNumber) {
-    try {
-      return fieldInfo(fieldNumber).name;
-    }
-    catch (NullPointerException npe) {
-      return "";
-    }
+	FieldInfo fi = fieldInfo(fieldNumber);
+	return (fi != null) ? fi.name : "";
   }
 
   /**
@@ -268,12 +257,7 @@
    * doesn't exist.
    */  
   public FieldInfo fieldInfo(int fieldNumber) {
-    try {
-      return (FieldInfo) byNumber.get(fieldNumber);
-    }
-    catch (IndexOutOfBoundsException ioobe) {
-      return null;
-    }
+	return (fieldNumber >= 0) ? (FieldInfo) byNumber.get(fieldNumber) : null;
   }
 
   public int size() {



Mime
View raw message