This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push: new 6d7a83d Avoid an ArithmeticException when formatting an infinite value as a date. It does not resolve the problem for high but non-infinite values however. 6d7a83d is described below commit 6d7a83dc182ea659a1b7d7891ce0b96cf753a9b3 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Wed Mar 16 11:57:32 2022 +0100 Avoid an ArithmeticException when formatting an infinite value as a date. It does not resolve the problem for high but non-infinite values however. --- .../main/java/org/apache/sis/geometry/CoordinateFormat.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/CoordinateFormat.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/CoordinateFormat.java index 5165fbc..3b56f5e 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/CoordinateFormat.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/CoordinateFormat.java @@ -1364,6 +1364,7 @@ abort: if (dimensions != 0 && groundAccuracy != null) try { * @param position the coordinate to format. * @param toAppendTo where the text is to be appended. * @throws IOException if an error occurred while writing to the given appendable. + * @throws ArithmeticException if a date value exceed the capacity of {@code long} type. */ @Override @SuppressWarnings({"UnnecessaryBoxing", "null"}) @@ -1434,7 +1435,16 @@ abort: if (dimensions != 0 && groundAccuracy != null) try { case LONGITUDE: valueObject = new Longitude (value); break; case LATITUDE: valueObject = new Latitude (value); break; case ANGLE: valueObject = new Angle (value); break; - case DATE: valueObject = new Date(Math.addExact(Math.round(value), epochs[i])); break; + case DATE: { + if (Double.isFinite(value)) { + valueObject = new Date(Math.addExact(Math.round(value), epochs[i])); + } else { + if (i != 0) toAppendTo.append(separator); + toAppendTo.append(String.valueOf(value)); + continue; + } + break; + } } } else { valueObject = value;