Fix a possible NPE in HiddenErrorHandler

From our server logs I observe that sporadically the
HttpConnection.getCurrentConnection() returns null which causes a NPE
in the HiddenErrorHandler.message method.

Change-Id: Ib34ccf49482cd051d9c3609c3876cc4993ec6eb1
This commit is contained in:
Saša Živkov
2016-08-25 17:38:16 +02:00
committed by David Pursehouse
parent 226abb7873
commit 1a004d3e3e

View File

@@ -64,10 +64,15 @@ class HiddenErrorHandler extends ErrorHandler {
}
private static byte[] message(HttpConnection conn) {
String msg = conn.getHttpChannel().getResponse().getReason();
if (msg == null) {
msg = HttpStatus.getMessage(conn.getHttpChannel()
.getResponse().getStatus());
String msg;
if (conn == null) {
msg = "";
} else {
msg = conn.getHttpChannel().getResponse().getReason();
if (msg == null) {
msg = HttpStatus.getMessage(conn.getHttpChannel()
.getResponse().getStatus());
}
}
return msg.getBytes(ISO_8859_1);
}