mirror of https://github.com/apache/lucene.git
Revert "SOLR-14767 : Fix NumberFormatException when int/long field value is floating num"
This reverts commit 63f0b6b706
.
This commit is contained in:
parent
52183dfbf6
commit
274a3d69d2
|
@ -251,9 +251,6 @@ Bug Fixes
|
|||
* SOLR-14850: Fix ExactStatsCache NullPointerException when shards.tolerant=true.
|
||||
(Yevhen Tienkaiev via ab)
|
||||
|
||||
* SOLR-14767: Fix NumberFormatException when integer/long field value is specified as floating number
|
||||
(Apoorv Bhawsar, Munendra S N)
|
||||
|
||||
* SOLR-14897: Fix unlimited number of forwarding the request from one node to another node. (hossman, Munendra S N)
|
||||
|
||||
* SOLR-14898: Stop returning duplicate HTTP response headers when requests are forward to another node. (hossman)
|
||||
|
|
|
@ -51,7 +51,8 @@ public class IntPointField extends PointField implements IntValueFieldType {
|
|||
try {
|
||||
if (val instanceof CharSequence) return Integer.parseInt( val.toString());
|
||||
} catch (NumberFormatException e) {
|
||||
return (int)Float.parseFloat(val.toString());
|
||||
Float v = Float.parseFloat(val.toString());
|
||||
return v.intValue();
|
||||
}
|
||||
return super.toNativeType(val);
|
||||
}
|
||||
|
@ -145,16 +146,7 @@ public class IntPointField extends PointField implements IntValueFieldType {
|
|||
|
||||
@Override
|
||||
public IndexableField createField(SchemaField field, Object value) {
|
||||
int intValue;
|
||||
if (value instanceof Number) {
|
||||
intValue = ((Number) value).intValue();
|
||||
} else {
|
||||
try {
|
||||
intValue = Integer.parseInt(value.toString());
|
||||
} catch (NumberFormatException e) {
|
||||
intValue = (int) Float.parseFloat(value.toString());
|
||||
}
|
||||
}
|
||||
int intValue = (value instanceof Number) ? ((Number) value).intValue() : Integer.parseInt(value.toString());
|
||||
return new IntPoint(field.getName(), intValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ public class LongPointField extends PointField implements LongValueFieldType {
|
|||
try {
|
||||
if (val instanceof CharSequence) return Long.parseLong(val.toString());
|
||||
} catch (NumberFormatException e) {
|
||||
return (long)Double.parseDouble(val.toString());
|
||||
Double v = Double.parseDouble(val.toString());
|
||||
return v.longValue();
|
||||
}
|
||||
return super.toNativeType(val);
|
||||
}
|
||||
|
@ -150,16 +151,7 @@ public class LongPointField extends PointField implements LongValueFieldType {
|
|||
|
||||
@Override
|
||||
public IndexableField createField(SchemaField field, Object value) {
|
||||
long longValue;
|
||||
if (value instanceof Number) {
|
||||
longValue = ((Number) value).longValue();
|
||||
} else {
|
||||
try {
|
||||
longValue = Long.parseLong(value.toString());
|
||||
} catch (NumberFormatException e) {
|
||||
longValue = (long) Double.parseDouble(value.toString());
|
||||
}
|
||||
}
|
||||
long longValue = (value instanceof Number) ? ((Number) value).longValue() : Long.parseLong(value.toString());
|
||||
return new LongPoint(field.getName(), longValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -553,16 +553,9 @@ public class TrieField extends NumericFieldType {
|
|||
|
||||
switch (type) {
|
||||
case INTEGER:
|
||||
int i;
|
||||
if (value instanceof Number) {
|
||||
i = ((Number) value).intValue();
|
||||
} else {
|
||||
try {
|
||||
i = Integer.parseInt(value.toString());
|
||||
} catch (NumberFormatException e) {
|
||||
i = (int) Float.parseFloat(value.toString());
|
||||
}
|
||||
}
|
||||
int i = (value instanceof Number)
|
||||
? ((Number)value).intValue()
|
||||
: Integer.parseInt(value.toString());
|
||||
f = new LegacyIntField(field.getName(), i, ft);
|
||||
break;
|
||||
case FLOAT:
|
||||
|
@ -572,16 +565,9 @@ public class TrieField extends NumericFieldType {
|
|||
f = new LegacyFloatField(field.getName(), fl, ft);
|
||||
break;
|
||||
case LONG:
|
||||
long l;
|
||||
if (value instanceof Number) {
|
||||
l = ((Number) value).longValue();
|
||||
} else {
|
||||
try {
|
||||
l = Long.parseLong(value.toString());
|
||||
} catch (NumberFormatException e) {
|
||||
l = (long) Double.parseDouble(value.toString());
|
||||
}
|
||||
}
|
||||
long l = (value instanceof Number)
|
||||
? ((Number)value).longValue()
|
||||
: Long.parseLong(value.toString());
|
||||
f = new LegacyLongField(field.getName(), l, ft);
|
||||
break;
|
||||
case DOUBLE:
|
||||
|
|
|
@ -238,14 +238,4 @@ public class TestUpdate extends SolrTestCaseJ4 {
|
|||
fail();
|
||||
}
|
||||
|
||||
@Test // SOLR-14767
|
||||
public void testStringUpdateOnLongAndIntFields() throws Exception {
|
||||
clearIndex();
|
||||
|
||||
addAndGetVersion(sdoc("id","1", "val_is", "42.0", "val_is", 12, "val_i", "12.1", "val_l",
|
||||
"42.0", "val_ll", "12.1", "val_ll", "32"), null);
|
||||
assertJQ(req("qt","/get", "id","1", "fl","id,val*")
|
||||
,"=={'doc':{'id':'1', 'val_i':12, 'val_is':[42,12], 'val_l':42, 'val_ll':[12,32]}}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue