You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 1, 2019. It is now read-only.
Funny bug that i've discovered, when mistakenly set timeout to 10 milliseconds
the bug in this code
void fill(URLConnection anUrlConnection) throws IOException {
urlConnection = anUrlConnection;
try {
inputStream = anUrlConnection.getInputStream();
} catch (IOException e) {
// Per http://docs.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html
// (comparable documentation exists for later java versions)
// if an HttpURLConnection was used clear the errorStream and close it
// so that keep alive can keep doing its work
if (anUrlConnection instanceof HttpURLConnection) {
HttpURLConnection conn = (HttpURLConnection) anUrlConnection;
InputStream es = new BufferedInputStream(conn.getErrorStream());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// read the response body
byte[] buf = new byte[1024];
int read = -1;
while ((read = es.read(buf)) > 0) {
baos.write(buf, 0, read);
}
// close the errorstream
es.close();
throw new IOException("Error while reading from " + conn.getRequestMethod() + ": [" + conn.getResponseCode() + "] "
+ conn.getResponseMessage() + "\n" + new String(baos.toByteArray(), "UTF-8"), e);
} else {
throw e;
}
}
}
we are trying to read output while stream is already closed by urlConnections so never reaching throw section
The text was updated successfully, but these errors were encountered:
Funny bug that i've discovered, when mistakenly set timeout to 10 milliseconds
the bug in this code
void fill(URLConnection anUrlConnection) throws IOException {
urlConnection = anUrlConnection;
try {
inputStream = anUrlConnection.getInputStream();
} catch (IOException e) {
// Per http://docs.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html
// (comparable documentation exists for later java versions)
// if an HttpURLConnection was used clear the errorStream and close it
// so that keep alive can keep doing its work
if (anUrlConnection instanceof HttpURLConnection) {
HttpURLConnection conn = (HttpURLConnection) anUrlConnection;
InputStream es = new BufferedInputStream(conn.getErrorStream());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// read the response body
byte[] buf = new byte[1024];
int read = -1;
while ((read = es.read(buf)) > 0) {
baos.write(buf, 0, read);
}
// close the errorstream
es.close();
throw new IOException("Error while reading from " + conn.getRequestMethod() + ": [" + conn.getResponseCode() + "] "
+ conn.getResponseMessage() + "\n" + new String(baos.toByteArray(), "UTF-8"), e);
} else {
throw e;
}
}
}
we are trying to read output while stream is already closed by urlConnections so never reaching throw section
—
Reply to this email directly or view it on GitHub.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Funny bug that i've discovered, when mistakenly set timeout to 10 milliseconds
the bug in this code
void fill(URLConnection anUrlConnection) throws IOException {
urlConnection = anUrlConnection;
try {
inputStream = anUrlConnection.getInputStream();
} catch (IOException e) {
// Per http://docs.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html
// (comparable documentation exists for later java versions)
// if an HttpURLConnection was used clear the errorStream and close it
// so that keep alive can keep doing its work
if (anUrlConnection instanceof HttpURLConnection) {
HttpURLConnection conn = (HttpURLConnection) anUrlConnection;
InputStream es = new BufferedInputStream(conn.getErrorStream());
we are trying to read output while stream is already closed by urlConnections so never reaching throw section
The text was updated successfully, but these errors were encountered: