summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-12-13 21:25:04 +0100
committerGitHub <noreply@github.com>2023-12-13 21:25:04 +0100
commitd976f82207c09b3215661e1d034ae9a42f28a63d (patch)
tree2d301a94e4326e1b9493f77a8b4419073de6a379 /config-model
parent4f48e420144ab7288fe45406bd4d1ea69de6eecb (diff)
Revert "add parsing of special strings for inf/nan cell values"
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidator.java16
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidatorTest.java9
2 files changed, 3 insertions, 22 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidator.java
index 9f1c072ad8b..fcb99215565 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidator.java
@@ -7,8 +7,6 @@ import com.fasterxml.jackson.core.JsonToken;
import com.google.common.base.Joiner;
import com.yahoo.tensor.TensorType;
-import static com.yahoo.tensor.serialization.JsonFormat.decodeNumberString;
-
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
@@ -284,19 +282,9 @@ public class ConstantTensorJsonValidator {
}
private void validateNumeric(String where, JsonToken token) throws IOException {
- if (token == JsonToken.VALUE_NUMBER_FLOAT || token == JsonToken.VALUE_NUMBER_INT || token == JsonToken.VALUE_NULL) {
- return; // ok
- }
- if (token == JsonToken.VALUE_STRING) {
- String input = parser.getValueAsString();
- try {
- double d = decodeNumberString(input);
- return;
- } catch (NumberFormatException e) {
- throw new InvalidConstantTensorException(parser, String.format("Inside '%s': %s", where, e.getMessage()));
- }
+ if (token != JsonToken.VALUE_NUMBER_FLOAT && token != JsonToken.VALUE_NUMBER_INT) {
+ throw new InvalidConstantTensorException(parser, String.format("Inside '%s': cell value is not a number (%s)", where, token.toString()));
}
- throw new InvalidConstantTensorException(parser, String.format("Inside '%s': cell value is not a number (%s)", where, token.toString()));
}
private void assertCurrentTokenIs(JsonToken wantedToken) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidatorTest.java
index 9171aae170c..4892c9acefa 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidatorTest.java
@@ -208,7 +208,7 @@ public class ConstantTensorJsonValidatorTest {
" ]",
"}"));
});
- assertTrue(exception.getMessage().contains("Inside 'value': Excepted a number, got string 'fruit'"));
+ assertTrue(exception.getMessage().contains("Inside 'value': cell value is not a number (VALUE_STRING)"));
}
@Test
@@ -295,13 +295,6 @@ public class ConstantTensorJsonValidatorTest {
}
@Test
- void ensure_that_values_can_contain_special_values() {
- validateTensorJson(
- TensorType.fromSpec("tensor(x[5])"),
- inputJsonToReader("['Infinity','+inf','NaN','-infinity','-nan']"));
- }
-
- @Test
void ensure_that_simple_object_for_map_works() {
validateTensorJson(
TensorType.fromSpec("tensor(x{})"),