diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index 98bb147d07..67062e0cab 100755 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -384,7 +384,7 @@ public abstract class BaseComputeServiceLiveTest { assertLocationSameOrChild(metadata.getLocation(), template.getLocation()); checkImageIdMatchesTemplate(metadata); checkOsMatchesTemplate(metadata); - assertEquals(metadata.getState(), NodeState.RUNNING); + assert (metadata.getState() == NodeState.RUNNING) : metadata; // due to DHCP the addresses can actually change in-between runs. assertEquals(metadata.getPrivateAddresses().size(), node.getPrivateAddresses().size()); assertEquals(metadata.getPublicAddresses().size(), node.getPublicAddresses().size()); diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/handlers/ParseSlicehostErrorFromHttpResponse.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/handlers/ParseSlicehostErrorFromHttpResponse.java index 7ea35b9059..0884259b24 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/handlers/ParseSlicehostErrorFromHttpResponse.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/handlers/ParseSlicehostErrorFromHttpResponse.java @@ -32,12 +32,10 @@ import javax.inject.Singleton; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpException; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.io.Payload; import org.jclouds.logging.Logger; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ResourceNotFoundException; @@ -111,15 +109,8 @@ public class ParseSlicehostErrorFromHttpResponse implements HttpErrorHandler { this.errorHandlerProvider = errorHandlerProvider; } - String parse(Payload in) { - try { - return factory.create(errorHandlerProvider.get()).parse(in.getInput()); - } catch (HttpException e) { - logger.warn(e, "error parsing error"); - return null; - } finally { - in.release(); - } + String parse(String in) { + return factory.create(errorHandlerProvider.get()).parse(in); } } @@ -127,16 +118,10 @@ public class ParseSlicehostErrorFromHttpResponse implements HttpErrorHandler { String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { // slicehost returns " " which is unparsable if (response.getPayload() != null) { - String contentType = response.getPayload().getContentMetadata().getContentType(); - if (response.getPayload().getContentMetadata().getContentLength() != 1) { - response.getPayload().release(); - } else if (contentType != null && contentType.indexOf("xml") != -1) { - return errorParser.parse(response.getPayload()); - } else { - try { - return Strings2.toStringAndClose(response.getPayload().getInput()); - } catch (IOException e) { - } + try { + String payload = Strings2.toStringAndClose(response.getPayload().getInput()).trim(); + return payload.indexOf("xml") != -1 ? errorParser.parse(payload) : payload; + } catch (IOException e) { } } return null;