If load a property object from a XML stream from a http request then it would fail with IOException: stream is closed.
The cause is that ChunkedInputStream does not accept a read after a close. The problem occur only if there is a cache like with JNLP. With a cache it will detect with a read if there is EOF.
The bug might be in HttpInputStream.close(). It should not call after a first close(). A possible fix can be to set the outputStream to null on a call of close.
@Override
public void close () throws IOException {
try {
if (outputStream != null) {
if (read() != -1) {
cacheRequest.abort();
} else {
outputStream.close();
}
}
super.close ();
} catch (IOException ioex) {
if (cacheRequest != null) {
cacheRequest.abort();
}
throw ioex;
} finally {
HttpURLConnection.this.http = null;
checkResponseCredentials (true);
}
}
This problem occur with all Java versions.
java.io.IOException: stream is closed
at sun.net.www.http.ChunkedInputStream.ensureOpen(Unknown Source)
at sun.net.www.http.ChunkedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.close(Unknown Source)
at java.util.Properties.loadFromXML(Unknown Source)
A workaround is to copy the stream in another stream.
The cause is that ChunkedInputStream does not accept a read after a close. The problem occur only if there is a cache like with JNLP. With a cache it will detect with a read if there is EOF.
The bug might be in HttpInputStream.close(). It should not call after a first close(). A possible fix can be to set the outputStream to null on a call of close.
@Override
public void close () throws IOException {
try {
if (outputStream != null) {
if (read() != -1) {
cacheRequest.abort();
} else {
outputStream.close();
}
}
super.close ();
} catch (IOException ioex) {
if (cacheRequest != null) {
cacheRequest.abort();
}
throw ioex;
} finally {
HttpURLConnection.this.http = null;
checkResponseCredentials (true);
}
}
This problem occur with all Java versions.
java.io.IOException: stream is closed
at sun.net.www.http.ChunkedInputStream.ensureOpen(Unknown Source)
at sun.net.www.http.ChunkedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.close(Unknown Source)
at java.util.Properties.loadFromXML(Unknown Source)
A workaround is to copy the stream in another stream.