This change ensures that "wrapped" datasets created from NetcdfDataset.enhance or from netcdfDataset.toBuilder can close the original NetcdfDataset if it was acquired from the cache. A new wrapped NetcdfDataset cannot directly close the original in the cache when close is called, but it can delegate this to the origFile. So the origFile needs to point to whatever the wrapped object is. This makes the behavior between enhanced NetcdfDatasets and NetcdfFiles the same.
Add tests for this. Note before the fix tests two and four (shouldReleaseLockOnNetcdfDatasetUsingBuilder and shouldReleaseLockOnAggregation) failed.
Description of Changes
This change ensures that "wrapped" datasets created from
NetcdfDataset.enhance
or fromnetcdfDataset.toBuilder
can close the originalNetcdfDataset
if it was acquired from the cache. A new wrappedNetcdfDataset
cannot directly close the original in the cache whenclose
is called, but it can delegate this to theorigFile
. So theorigFile
needs to point to whatever the wrapped object is. This makes the behavior between enhancedNetcdfDatasets
andNetcdfFiles
the same.Add tests for this. Note before the fix tests two and four (
shouldReleaseLockOnNetcdfDatasetUsingBuilder
andshouldReleaseLockOnAggregation
) failed.Jenkins tests are passing on this branch: https://jenkins-aws.unidata.ucar.edu/view/Users/job/tara-netcdf-java/47/