check null before attempting to close a stream

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1440 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-06-17 23:00:22 +00:00
parent b858ec002e
commit ec11f2ef20
1 changed files with 10 additions and 10 deletions

View File

@ -37,14 +37,14 @@ import org.jclouds.util.Utils;
*/
public class CloseContentAndSetExceptionHandler implements HttpResponseHandler {
public void handle(HttpFutureCommand<?> command, HttpResponse response) {
String content;
try {
content = Utils.toStringAndClose(response.getContent());
command.setException(new HttpResponseException(command, response,
content));
} catch (IOException e) {
command.setException(new HttpResponseException(command, response));
}
}
public void handle(HttpFutureCommand<?> command, HttpResponse response) {
String content;
try {
content = response.getContent() != null ? Utils.toStringAndClose(response.getContent())
: null;
command.setException(new HttpResponseException(command, response, content));
} catch (IOException e) {
command.setException(new HttpResponseException(command, response));
}
}
}