diff --git a/cdm/core/src/main/java/ucar/nc2/internal/ncml/NcmlReader.java b/cdm/core/src/main/java/ucar/nc2/internal/ncml/NcmlReader.java index 9d316d9d02..e569910e5d 100644 --- a/cdm/core/src/main/java/ucar/nc2/internal/ncml/NcmlReader.java +++ b/cdm/core/src/main/java/ucar/nc2/internal/ncml/NcmlReader.java @@ -810,9 +810,9 @@ private void readDim(Group.Builder groupBuilder, @Nullable Group refGroup, Eleme String nameInFile = dimElem.getAttributeValue("orgName") != null ? dimElem.getAttributeValue("orgName") : name; - // LOOK this is wrong, groupBuilder may already have the dimension. // see if it already exists - Dimension dim = (refGroup == null) ? null : refGroup.findDimension(nameInFile); + Dimension dim = + (refGroup == null) ? groupBuilder.findDimension(nameInFile).orElse(null) : refGroup.findDimension(nameInFile); if (dim == null) { // nope - create it String lengthS = dimElem.getAttributeValue("length"); if (lengthS == null) {