Unidata / thredds

THREDDS Data Server v4.6
https://www.unidata.ucar.edu/software/tds/v4.6/index.html
265 stars 179 forks source link

NetcdfFile.open of GRIB2 file using relative path throws NullPointerException #58

Closed cambecc closed 10 years ago

cambecc commented 10 years ago

(using netcdf4-4.5.1)

REPRO:

mkdir -p ~/temp && cd ~/temp
wget "http://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.2014071900/gfs.t00z.master.grbf00.10m.uv.grib2"
public final class Driver {
    public static void main(String[] args) throws Exception {
        ucar.nc2.NetcdfFile.open("gfs.t00z.master.grbf00.10m.uv.grib2");
    }
}

RESULT:

Caused by: java.lang.NullPointerException
    at ucar.nc2.util.DiskCache2.canWrite(DiskCache2.java:256)
    at ucar.nc2.util.DiskCache2.getFile(DiskCache2.java:236)
    at ucar.nc2.grib.collection.GribCollection.getFileInCache(GribCollection.java:203)
    at ucar.nc2.grib.grib2.Grib2Index.readIndex(Grib2Index.java:119)
    at ucar.nc2.grib.GribIndex.readOrCreateIndexFromSingleFile(GribIndex.java:100)
    at ucar.nc2.grib.collection.Grib2CollectionBuilder.makeGroups(Grib2CollectionBuilder.java:115)
    at ucar.nc2.grib.collection.GribCollectionBuilder.createIndex(GribCollectionBuilder.java:117)
    at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromDataFile(GribCdmIndex.java:632)
    at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromDataFile(GribCdmIndex.java:616)
    at ucar.nc2.grib.collection.GribCdmIndex.makeGribCollectionFromRaf(GribCdmIndex.java:585)
    at ucar.nc2.grib.collection.GribIosp.open(GribIosp.java:181)
    at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1527)
    at ucar.nc2.NetcdfFile.open(NetcdfFile.java:819)
    at ucar.nc2.NetcdfFile.open(NetcdfFile.java:427)
    ... 4 more

To workaround this bug, use an absolute path to open the file:

    ucar.nc2.NetcdfFile.open("/home/bob/temp/gfs.t00z.master.grbf00.10m.uv.grib2");
JohnLCaron commented 10 years ago

Hi Cameron:

Thanks for report, will fix !

John