// We CAN NOT close the parent stream right away, because then we would
// invalidate
// the returned stream. Instead we have to wait until the returned stream is
// closed as
// well.
return new InputStreamWrapper(inputStream) {
@Override
public void close() throws IOException {
super.close();
inputStream.close();
}