HADOOP-14841 Kms client should disconnect if unable to get output stream from connection. Contributed by Rushabh S Shah
This commit is contained in:
parent
96c843f64b
commit
4cdbdce752
@ -447,12 +447,21 @@ private <T> T call(HttpURLConnection conn, Object jsonOutput,
|
||||
int expectedResponse, Class<T> klass, int authRetryCount)
|
||||
throws IOException {
|
||||
T ret = null;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
if (jsonOutput != null) {
|
||||
writeJson(jsonOutput, conn.getOutputStream());
|
||||
os = conn.getOutputStream();
|
||||
writeJson(jsonOutput, os);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
IOUtils.closeStream(conn.getInputStream());
|
||||
// The payload is not serialized if getOutputStream fails.
|
||||
// Calling getInputStream will issue the put/post request with no payload
|
||||
// which causes HTTP 500 server error.
|
||||
if (os == null) {
|
||||
conn.disconnect();
|
||||
} else {
|
||||
IOUtils.closeStream(conn.getInputStream());
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
if ((conn.getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN
|
||||
|
Loading…
Reference in New Issue
Block a user