diff --git a/cdm/zarr/src/main/java/ucar/nc2/iosp/zarr/ZarrHeader.java b/cdm/zarr/src/main/java/ucar/nc2/iosp/zarr/ZarrHeader.java index a1734bf658..24854661f6 100644 --- a/cdm/zarr/src/main/java/ucar/nc2/iosp/zarr/ZarrHeader.java +++ b/cdm/zarr/src/main/java/ucar/nc2/iosp/zarr/ZarrHeader.java @@ -227,7 +227,8 @@ private void makeVariable(RandomAccessDirectoryItem item, long dataOffset, ZArra private List makeAttributes(RandomAccessDirectoryItem item) { // get RandomAccessFile for JSON parsing - try (RandomAccessFile raf = item.getOrOpenRaf()) { + try { + RandomAccessFile raf = item.getOrOpenRaf(); // read attributes from file raf.seek(0); Map attrMap = objectMapper.readValue(raf, HashMap.class); diff --git a/cdm/zarr/src/main/java/ucar/nc2/iosp/zarr/ZarrIosp.java b/cdm/zarr/src/main/java/ucar/nc2/iosp/zarr/ZarrIosp.java index 15bf286267..971d102473 100644 --- a/cdm/zarr/src/main/java/ucar/nc2/iosp/zarr/ZarrIosp.java +++ b/cdm/zarr/src/main/java/ucar/nc2/iosp/zarr/ZarrIosp.java @@ -139,4 +139,9 @@ private Object getFillValue(ZarrHeader.VInfo vinfo, DataType dataType) { } return fillValue; } + + @Override + public long getLastModified() { + return raf.getLastModified(); + } } diff --git a/cdm/zarr/src/test/java/ucar/nc2/iosp/zarr/TestZarrIosp.java b/cdm/zarr/src/test/java/ucar/nc2/iosp/zarr/TestZarrIosp.java index 7eb8f7e653..e2f93781fd 100644 --- a/cdm/zarr/src/test/java/ucar/nc2/iosp/zarr/TestZarrIosp.java +++ b/cdm/zarr/src/test/java/ucar/nc2/iosp/zarr/TestZarrIosp.java @@ -296,4 +296,12 @@ public void testFillValues() throws IOException { assertThat(double_ninf.getDouble(0)).isEqualTo(Double.NEGATIVE_INFINITY); } + @Test + public void testLastModified() throws IOException { + for (String uri : stores) { + try (NetcdfFile ncfile = NetcdfFiles.open(uri)) { + assertThat(ncfile.getLastModified()).isNotEqualTo(0); + } + } + } }