Skip to content

Commit

Permalink
Fix renamed dimension in aggregations where refGroup may be null
Browse files Browse the repository at this point in the history
  • Loading branch information
tdrwenski committed Apr 15, 2024
1 parent dabd06e commit c23e2dd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cdm/core/src/main/java/ucar/nc2/internal/ncml/NcmlReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,11 @@ 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);
Optional<Dimension> dimFromAgg = groupBuilder.findDimension(nameInFile);
Dimension dim = (refGroup == null || dimFromAgg.isPresent())
? dimFromAgg.orElse(null) : refGroup.findDimension(nameInFile);

if (dim == null) { // nope - create it
String lengthS = dimElem.getAttributeValue("length");
if (lengthS == null) {
Expand Down

0 comments on commit c23e2dd

Please sign in to comment.