HADOOP-14385. HttpExceptionUtils#validateResponse swallows exceptions. Contributed by Wei-Chiu Chuang.

Signed-off-by: Wei-Chiu Chuang <weichiu@apache.org>
(cherry picked from commit 840d02ca5b)
This commit is contained in:
Wei-Chiu Chuang 2019-06-20 19:57:09 -07:00
parent f046b881f6
commit 77e391fd8b
1 changed files with 7 additions and 5 deletions

View File

@ -154,18 +154,20 @@ public class HttpExceptionUtils {
toThrow = (Exception) constr.newInstance(exMsg); toThrow = (Exception) constr.newInstance(exMsg);
} catch (Exception ex) { } catch (Exception ex) {
toThrow = new IOException(String.format( toThrow = new IOException(String.format(
"HTTP status [%d], exception [%s], message [%s] ", "HTTP status [%d], exception [%s], message [%s], URL [%s]",
conn.getResponseCode(), exClass, exMsg)); conn.getResponseCode(), exClass, exMsg, conn.getURL()));
} }
} else { } else {
String msg = (exMsg != null) ? exMsg : conn.getResponseMessage(); String msg = (exMsg != null) ? exMsg : conn.getResponseMessage();
toThrow = new IOException(String.format( toThrow = new IOException(String.format(
"HTTP status [%d], message [%s]", conn.getResponseCode(), msg)); "HTTP status [%d], message [%s], URL [%s]",
conn.getResponseCode(), msg, conn.getURL()));
} }
} catch (Exception ex) { } catch (Exception ex) {
toThrow = new IOException(String.format( toThrow = new IOException(String.format(
"HTTP status [%d], message [%s]", conn.getResponseCode(), "HTTP status [%d], message [%s], URL [%s], exception [%s]",
conn.getResponseMessage())); conn.getResponseCode(), conn.getResponseMessage(), conn.getURL(),
ex.toString()), ex);
} finally { } finally {
if (es != null) { if (es != null) {
try { try {