From ec11f2ef20ecda4e57e7ea4b5a316f0b3eafee1c Mon Sep 17 00:00:00 2001 From: "adrian.f.cole" Date: Wed, 17 Jun 2009 23:00:22 +0000 Subject: [PATCH] check null before attempting to close a stream git-svn-id: http://jclouds.googlecode.com/svn/trunk@1440 3d8758e0-26b5-11de-8745-db77d3ebf521 --- .../CloseContentAndSetExceptionHandler.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/jclouds/http/handlers/CloseContentAndSetExceptionHandler.java b/core/src/main/java/org/jclouds/http/handlers/CloseContentAndSetExceptionHandler.java index fc3d2d89c3..9f915b3f7c 100644 --- a/core/src/main/java/org/jclouds/http/handlers/CloseContentAndSetExceptionHandler.java +++ b/core/src/main/java/org/jclouds/http/handlers/CloseContentAndSetExceptionHandler.java @@ -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)); + } + } }