From ff55b74bce98276a579fe3dc3ecae97144bc89a3 Mon Sep 17 00:00:00 2001 From: Sean Arms <67096+lesserwhirls@users.noreply.github.com> Date: Tue, 14 Jul 2026 16:22:19 -0600 Subject: [PATCH] xpublish DAP2 implementation compatibility In the xpublish implementation of the DAP2 das response, Not a Number values for attributes are represented by the string nan. However, in Java and other languages, the string representation is NaN, and thus netCDF-Java fails to parse the value. Fixes unidata/netcdf-java#1581 --- opendap/src/main/java/ucar/nc2/dods/DODSAttribute.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/opendap/src/main/java/ucar/nc2/dods/DODSAttribute.java b/opendap/src/main/java/ucar/nc2/dods/DODSAttribute.java index 0394f329ce..0f670c97d8 100644 --- a/opendap/src/main/java/ucar/nc2/dods/DODSAttribute.java +++ b/opendap/src/main/java/ucar/nc2/dods/DODSAttribute.java @@ -75,7 +75,14 @@ public DODSAttribute(String dodsName, opendap.dap.Attribute att) { data = Array.factory(ncType, new int[] {nvals}); Index ima = data.getIndex(); for (int i = 0; i < nvals; i++) { - double dval = Double.parseDouble(vals[i]); + double dval; + try { + dval = Double.parseDouble(vals[i]); + } catch (NumberFormatException e) { + // could be a python, rust (perhaps others) based server, in which case the string representation of NaN is + // nan + dval = Double.parseDouble(vals[i].replace("nan", "NaN")); + } data.setDouble(ima.set(i), dval); } } catch (NumberFormatException e) {