Open elzbietaa opened 5 years ago
@DennisHeimbigner - can you take a look at this one?
ok
It turns out this issue is related to this one: https://github.com/Unidata/thredds/issues/1211#issuecomment-460380193 Apparently when an array is created whose size is zero, some piece of code (probably in H5Iosp) decides that the Array needs a fill value, and creates one if not specified. later, when H5Iop.readData is called, it attempts to return that fillvalue as the data. This is probably because (as noted in the other issue) the size is one, not zero. In any case, the created fillvalue is an empty byte[] object. When an attempt is made to convert to Object[], it fails as noted on a ClassCastException. Not sure yet, what the proper solution is.
Just note that the issue occurs only for empty Structure
s or members of an empty Structure
.
With empty ucar.nc2.dataset.VariableDS
no exception is thrown.
The following test passes without problems:
@Test
public void testReadAVariableDs() throws IOException {
URL ncfile = getClass().getClassLoader()
.getResource("psenterprise/gsa/netcdf/odnc4_empty_structures.nc");
String variablePath = "/elevation";
try (NetcdfDataset dataSet = NetcdfDataset.acquireDataset(null, ncfile.toString(),
EnumSet.noneOf(NetcdfDataset.Enhance.class), -1, null, null)) {
Variable var = dataSet.findVariable(variablePath);
assertThat(var, is(notNullValue()));
dataSet.readArrays(ImmutableList.of(var));
}
}
CCE-problem-report.zip
Summary:
The following
ClassCastException
is thrown when trying to read data from an empty Structure:Notes:
ncgen -b odnc4_empty_structures.cdl
(see the attached .zip file for both the .cdl and the .nc file).Example test cases highlighting the issue are:
1) For an empty structure:
2) For a member of an empty structure: