mirror of https://github.com/apache/lucene.git
LUCENE-939: Check explicitly for boundary conditions in FieldInfos.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@558917 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e97d5830ce
commit
273d28f000
|
@ -1,4 +1,4 @@
|
|||
Lucene Change Log
|
||||
Lucene Change Log
|
||||
|
||||
$Id$
|
||||
|
||||
|
@ -80,6 +80,9 @@ Optimizations
|
|||
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
|
||||
|
||||
Build
|
||||
|
|
|
@ -230,15 +230,8 @@ final class FieldInfos {
|
|||
}
|
||||
|
||||
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 @@ final class FieldInfos {
|
|||
* 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 @@ final class FieldInfos {
|
|||
* 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() {
|
||||
|
|
Loading…
Reference in New Issue