You probably close the stream (try-with-resource) when you throw an exception. Try to define a separate stream and wrap it with StreamingResponseBody and then the exception will be handled correctly @ControllerAdvice.
StreamingResponseBody responseBody = outputStream -> {
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
//some logic here
byteArrayOutputStream.writeTo(outputStream);
} catch (IOException e) {
//byteArrayOutputStream will be closed but not outputStream
log.error("Error occurred while streaming: {}", e.getMessage(), e);
throw new CustomException("Error due to I/O issues.", e);
}
}