You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.
The following ClassCastException is thrown when trying to read data from an empty Structure:
java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object;
at ucar.ma2.Array.factory(Array.java:181)
at ucar.ma2.Array.factory(Array.java:160)
at ucar.nc2.iosp.hdf5.H5iosp.readData(H5iosp.java:155)
at ucar.nc2.iosp.hdf5.H5iosp.readData(H5iosp.java:141)
at ucar.nc2.NetcdfFile.readData(NetcdfFile.java:2020)
at ucar.nc2.Variable.reallyRead(Variable.java:874)
at ucar.nc2.Variable._read(Variable.java:845)
at ucar.nc2.Variable.read(Variable.java:723)
at ucar.nc2.dataset.StructureDS.reallyRead(StructureDS.java:232)
at ucar.nc2.Variable._read(Variable.java:845)
at ucar.nc2.Variable.read(Variable.java:723)
at ucar.nc2.NetcdfFile.readArrays(NetcdfFile.java:2142)
...
Notes:
same happens when the Variable indicates a member of an empty Structure
It turns out this issue is related to this one: #1211 (comment)
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 Structures or members of an empty Structure.
With empty ucar.nc2.dataset.VariableDS no exception is thrown.
CCE-problem-report.zip
Summary:
The following
ClassCastException
is thrown when trying to read data from an empty Structure:Notes:
https://www.unidata.ucar.edu/software/netcdf/workshops/2010/groups-types/popup_groups-types_ObsDataExample_1.html via
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:
The text was updated successfully, but these errors were encountered: