Issue #1786 - fix null pointer

Change-Id: Ie7bf3aa9afe6a8dcd9d288afc0e6dc537fdf043d

Former-commit-id: 7701902083 [formerly 6f14dfd04a696c71e2b2c9d12b86549287e7f0de]
Former-commit-id: 6b909c7902
This commit is contained in:
Mike Duff 2013-04-16 14:21:28 -05:00
parent 30e77171ab
commit ad08e0a6ac

View file

@ -201,10 +201,18 @@ public class HttpClient {
public void process(final HttpRequest request, public void process(final HttpRequest request,
final HttpContext context) throws HttpException, final HttpContext context) throws HttpException,
IOException { IOException {
if (request.getFirstHeader("Content-Length") != null) { try {
logBytes( if (request != null
Long.valueOf(request.getFirstHeader( && request.getFirstHeader("Content-Length") != null) {
"Content-Length").getValue()), 0); logBytes(
Long.valueOf(request.getFirstHeader(
"Content-Length").getValue()),
0);
}
} catch (Throwable t) {
statusHandler.handle(Priority.DEBUG,
"Error in httpClient request interceptor",
t);
} }
} }
}); });
@ -214,7 +222,18 @@ public class HttpClient {
public void process(final HttpResponse response, public void process(final HttpResponse response,
final HttpContext context) throws HttpException, final HttpContext context) throws HttpException,
IOException { IOException {
logBytes(0, response.getEntity().getContentLength()); try {
if (response != null
&& response.getEntity() != null) {
logBytes(0, response.getEntity()
.getContentLength());
}
} catch (Throwable t) {
statusHandler
.handle(Priority.DEBUG,
"Error in httpsClient response interceptor",
t);
}
} }
}); });
@ -280,10 +299,16 @@ public class HttpClient {
public void process(final HttpRequest request, public void process(final HttpRequest request,
final HttpContext context) throws HttpException, final HttpContext context) throws HttpException,
IOException { IOException {
if (request.getFirstHeader("Content-Length") != null) { try {
logBytes( if (request != null
Long.valueOf(request.getFirstHeader( && request.getFirstHeader("Content-Length") != null) {
"Content-Length").getValue()), 0); logBytes(
Long.valueOf(request.getFirstHeader(
"Content-Length").getValue()), 0);
}
} catch (Throwable t) {
statusHandler.handle(Priority.DEBUG,
"Error in httpClient request interceptor", t);
} }
} }
}); });
@ -293,7 +318,14 @@ public class HttpClient {
public void process(final HttpResponse response, public void process(final HttpResponse response,
final HttpContext context) throws HttpException, final HttpContext context) throws HttpException,
IOException { IOException {
logBytes(0, response.getEntity().getContentLength()); try {
if (response != null && response.getEntity() != null) {
logBytes(0, response.getEntity().getContentLength());
}
} catch (Throwable t) {
statusHandler.handle(Priority.DEBUG,
"Error in httpClient response interceptor", t);
}
} }
}); });