GZIPResponseStream should not throw Exception on flushing

Description

Forcing GZIPResponseStream to throw an Exception when flushing if the stream is closed can cause, wrongly, unwanted exceptions.

https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/filters/GZIPResponse
Stream.java#L38

The check above should instead just avoid flushing again if the stream is already closed

{{ public void flush() throws IOException {
if (!closed) {
gzipstream.flush();
}
}}}

This happens especially on servlet filter chains. Very often it happens that a filter closes the stream. Since this is the last one called if the content-type can be compressed, it is highly probable that this will end throwing a wrong Exception.

To reproduce the error, as an instance, just try to recall the "Importer" plugin REST Endpoint from cUrl instead of a Browser.

Environment

None

Status

Assignee

Alessio Fabiani

Reporter

Alessio Fabiani

Triage

None

Fix versions

None

Affects versions

None

Components

Priority

High
Configure