summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/query
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2019-09-04 09:51:40 +0200
committerGitHub <noreply@github.com>2019-09-04 09:51:40 +0200
commitd71937c4f9f3c7b69d6d39cbac1ccdce23df3abe (patch)
tree3dfe569c2a02b552088a05d040a90b03a5f5d9c2 /container-search/src/main/java/com/yahoo/search/query
parent9f0f6369499a7b0143d2342626a99afd8f1b6bfc (diff)
parent192ac99fb050f540cc4cac10024534df96f2b3bf (diff)
Merge pull request #10463 from vespa-engine/bratseth/document-parsing-error-messages
Bratseth/document parsing error messages
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/ParameterParser.java16
1 files changed, 6 insertions, 10 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/ParameterParser.java b/container-search/src/main/java/com/yahoo/search/query/ParameterParser.java
index 30a0d90c309..d358fa06977 100644
--- a/container-search/src/main/java/com/yahoo/search/query/ParameterParser.java
+++ b/container-search/src/main/java/com/yahoo/search/query/ParameterParser.java
@@ -18,15 +18,11 @@ public class ParameterParser {
* a couple of valid examples are "s" and "ms". Only a very small subset of
* SI prefixes are supported). If no unit is given, seconds are assumed.
*
- * @param value
- * some representation of a number of seconds
- * @param defaultValue
- * returned if value is null
+ * @param value some representation of a number of seconds
+ * @param defaultValue returned if value is null
* @return value as a number of milliseconds
- * @throws NumberFormatException
- * if value is not a Number instance and its String
- * representation cannot be parsed as a number followed
- * optionally by time unit
+ * @throws NumberFormatException if value is not a Number instance and its String
+ * representation cannot be parsed as a number followed optionally by time unit
*/
public static Long asMilliSeconds(Object value, Long defaultValue) {
if (value == null) {
@@ -40,13 +36,12 @@ public class ParameterParser {
}
private static Long parseTime(String time) throws NumberFormatException {
-
time = time.trim();
try {
int unitOffset = findUnitOffset(time);
double measure = Double.valueOf(time.substring(0, unitOffset));
double multiplier = parseUnit(time.substring(unitOffset));
- return Long.valueOf((long) (measure * multiplier));
+ return (long) (measure * multiplier);
} catch (RuntimeException e) {
throw new IllegalArgumentException("Error parsing " + quote(time), e);
}
@@ -85,4 +80,5 @@ public class ParameterParser {
}
return multiplier;
}
+
}