WCS multidimensional requests (NetCDF/Grib outputs) may lead to un-closed readers

Description

Multidimensional outputs make WCS generate a GranuleStackImpl as the output "coverage".
This plays badly with the coverage cleanup code here:
https://github.com/geoserver/geoserver/blob/cd45206f93c4c42388484b4a2a96bd469fde698f/src/wcs/src/main/java/org/geoserver/wcs/CoverageCleanerCallback.java#L68
because the GranuleStackImpl.getRenderedImage returns null:
https://github.com/geoserver/geoserver/blob/7076e763387f0f682d05959e5b2d10442be12cf2/src/wcs2_0/src/main/java/org/geoserver/wcs2_0/response/GranuleStackImpl.java#L101
thus preventing the "recursive cleanup" code that also ends up closing readers and the like (because it's based on the RenderedImage, not the coverage)

Indeed I don't see NetCDFImageReader.dispose ever being called in a debugger, while doing requests over NetCDF inputs doing multi-coverage NetCDF outputs.

Solution ideas:

  • Move the granuleStack interface to core, and have the cleaner callback recognize it and clean each single coverage in it

  • Make GranuleStackImple return a RenderedImageList and have CoverageCleanerCallback recognize and handle it correctly

Environment

None

Status

Assignee

Andrea Aime

Reporter

Andrea Aime

Triage

None

Fix versions

Affects versions

None

Components

Priority

Medium
Configure