diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/handlers/ParseAtmosErrorFromXmlContent.java b/apis/atmos/src/main/java/org/jclouds/atmos/handlers/ParseAtmosErrorFromXmlContent.java index 07d854d2ea..9c69e0787e 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/handlers/ParseAtmosErrorFromXmlContent.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/handlers/ParseAtmosErrorFromXmlContent.java @@ -71,7 +71,7 @@ public class ParseAtmosErrorFromXmlContent implements HttpErrorHandler { AtmosError error = null; if (response.getPayload() != null) { try { - String content = Strings2.toStringAndClose(response.getPayload().getInput()); + String content = Strings2.toString(response.getPayload()); if (content != null && content.indexOf('<') >= 0) { error = utils.parseAtmosErrorFromContent(command, response, Strings2.toInputStream(content)); } else { diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java index 04e9675a04..2cc5293544 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java @@ -239,14 +239,14 @@ public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest { private static void verifyHeadObject(AtmosClient connection, String path, String metadataValue) throws InterruptedException, ExecutionException, TimeoutException, IOException { AtmosObject getBlob = connection.headFile(path); - assertEquals(Strings2.toStringAndClose(getBlob.getPayload().getInput()), ""); + assertEquals(Strings2.toString(getBlob.getPayload()), ""); verifyMetadata(metadataValue, getBlob); } private static void verifyObject(AtmosClient connection, String path, String compare, String metadataValue) throws InterruptedException, ExecutionException, TimeoutException, IOException { AtmosObject getBlob = connection.readFile(path); - assertEquals(Strings2.toStringAndClose(getBlob.getPayload().getInput()), compare); + assertEquals(Strings2.toString(getBlob.getPayload()), compare); verifyMetadata(metadataValue, getBlob); } diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/handlers/ParseCloudLoadBalancersErrorFromHttpResponse.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/handlers/ParseCloudLoadBalancersErrorFromHttpResponse.java index 52dfbd2ff1..e494bb657f 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/handlers/ParseCloudLoadBalancersErrorFromHttpResponse.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/handlers/ParseCloudLoadBalancersErrorFromHttpResponse.java @@ -85,7 +85,7 @@ public class ParseCloudLoadBalancersErrorFromHttpResponse implements HttpErrorHa String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { if (response.getPayload() != null) { try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { logger.warn(e, "exception reading error from response", response); } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/handlers/ParseCloudServersErrorFromHttpResponse.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/handlers/ParseCloudServersErrorFromHttpResponse.java index 9fdaaa2576..6675d84d0c 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/handlers/ParseCloudServersErrorFromHttpResponse.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/handlers/ParseCloudServersErrorFromHttpResponse.java @@ -85,7 +85,7 @@ public class ParseCloudServersErrorFromHttpResponse implements HttpErrorHandler String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { if (response.getPayload() != null) { try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { logger.warn(e, "exception reading error from response", response); } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java index 453db3bc55..64995b1847 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java @@ -383,7 +383,7 @@ public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTes try { client.connect(); Payload etcPasswd = client.get("/etc/jclouds.txt"); - String etcPasswdContents = Strings2.toStringAndClose(etcPasswd.getInput()); + String etcPasswdContents = Strings2.toString(etcPasswd); assertEquals("rackspace", etcPasswdContents.trim()); } finally { if (client != null) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java index 7c784098a9..8c7f999f04 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java @@ -94,7 +94,7 @@ public class CloudSigmaErrorHandler implements HttpErrorHandler { if (response.getPayload() == null) return null; try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { throw new RuntimeException(e); } finally { diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java index 7c051ec7af..b2c7e984f9 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java @@ -92,7 +92,7 @@ public class CloudStackErrorHandler implements HttpErrorHandler { if (response.getPayload() == null) return null; try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { throw new RuntimeException(e); } finally { diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandler.java index 011bc0f042..73b5b7df85 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandler.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/handlers/DeltacloudErrorHandler.java @@ -87,7 +87,7 @@ public class DeltacloudErrorHandler implements HttpErrorHandler { if (response.getPayload() == null) return null; try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { throw new RuntimeException(e); } finally { diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/handlers/ElasticStackErrorHandler.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/handlers/ElasticStackErrorHandler.java index b55bb320e9..4ebc6471e0 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/handlers/ElasticStackErrorHandler.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/handlers/ElasticStackErrorHandler.java @@ -92,7 +92,7 @@ public class ElasticStackErrorHandler implements HttpErrorHandler { if (response.getPayload() == null) return null; try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { throw new RuntimeException(e); } finally { diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java index 1eea1798ea..badcb39087 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java @@ -326,7 +326,7 @@ public class ElasticStackClientLiveTest public void testWeCanReadAndWriteToDrive() throws IOException { drive2 = client.createDrive(new CreateDriveRequest.Builder().name(prefix + "2").size(1 * 1024 * 1024l).build()); client.writeDrive(drive2.getUuid(), Payloads.newStringPayload("foo")); - assertEquals(Strings2.toStringAndClose(client.readDrive(drive2.getUuid(), 0, 3).getInput()), "foo"); + assertEquals(Strings2.toString(client.readDrive(drive2.getUuid(), 0, 3)), "foo"); } @Test(dependsOnMethods = "testWeCanReadAndWriteToDrive") @@ -341,7 +341,7 @@ public class ElasticStackClientLiveTest assert driveNotClaimed.apply(drive2) : client.getDriveInfo(drive2.getUuid()); System.err.println("after image; drive 2" + client.getDriveInfo(drive2.getUuid())); System.err.println("after image; drive 3" + client.getDriveInfo(drive3.getUuid())); - assertEquals(Strings2.toStringAndClose(client.readDrive(drive3.getUuid(), 0, 3).getInput()), "foo"); + assertEquals(Strings2.toString(client.readDrive(drive3.getUuid(), 0, 3)), "foo"); } finally { client.destroyDrive(drive2.getUuid()); client.destroyDrive(drive3.getUuid()); diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/handlers/ParseNovaErrorFromHttpResponse.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/handlers/ParseNovaErrorFromHttpResponse.java index 8f3d08322e..496d8328c8 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/handlers/ParseNovaErrorFromHttpResponse.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/handlers/ParseNovaErrorFromHttpResponse.java @@ -85,7 +85,7 @@ public class ParseNovaErrorFromHttpResponse implements HttpErrorHandler { String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { if (response.getPayload() != null) { try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { logger.warn(e, "exception reading error from response", response); } diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java index 397ee7e907..7c5422686d 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java @@ -303,7 +303,7 @@ public class NovaClientLiveTest extends BaseComputeServiceContextLiveTest { try { client.connect(); Payload etcPasswd = client.get("/etc/jclouds.txt"); - String etcPasswdContents = Strings2.toStringAndClose(etcPasswd.getInput()); + String etcPasswdContents = Strings2.toString(etcPasswd); assertEquals("nova", etcPasswdContents.trim()); } finally { if (client != null) diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java index 774871ee65..b06413eac7 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java @@ -284,7 +284,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest { assertConsistencyAwareContainerSize(sourceContainer, 1); S3Object newObject = getApi().getObject(sourceContainer, key); assert newObject != null; - assertEquals(Strings2.toStringAndClose(newObject.getPayload().getInput()), TEST_STRING); + assertEquals(Strings2.toString(newObject.getPayload()), TEST_STRING); return newObject; } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientLiveTest.java index fb11ec3570..f80792dca0 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientLiveTest.java @@ -222,7 +222,7 @@ public abstract class CommonSwiftClientLiveTest ext assert getApi().getObject(containerName, "non-existent-object") == null; // Test GET of object (including updated metadata) SwiftObject getBlob = getApi().getObject(containerName, object.getInfo().getName()); - assertEquals(Strings2.toStringAndClose(getBlob.getPayload().getInput()), data); + assertEquals(Strings2.toString(getBlob.getPayload()), data); // TODO assertEquals(getBlob.getName(), // object.getMetadata().getName()); assertEquals(getBlob.getInfo().getBytes(), new Long(data.length())); @@ -267,7 +267,7 @@ public abstract class CommonSwiftClientLiveTest ext GetOptions.Builder.ifETagMatches(newEtag)); assertEquals(getBlob.getInfo().getHash(), CryptoStreams.hex(newEtag)); getBlob = getApi().getObject(containerName, object.getInfo().getName(), GetOptions.Builder.startAt(8)); - assertEquals(Strings2.toStringAndClose(getBlob.getPayload().getInput()), data.substring(8)); + assertEquals(Strings2.toString(getBlob.getPayload()), data.substring(8)); } finally { returnContainer(containerName); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java index d67e9114f3..3f206490b6 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java @@ -73,7 +73,7 @@ public class ParseVCloudErrorFromHttpResponse implements HttpErrorHandler { message = error.getMessage(); exception = new VCloudResponseException(command, response, error); } else { - message = Strings2.toStringAndClose(response.getPayload().getInput()); + message = Strings2.toString(response.getPayload()); exception = message != null ? new HttpResponseException(command, response, message) : exception; } } catch (IOException e) { diff --git a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java index 94a37faecc..f47d632bc9 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java @@ -65,7 +65,7 @@ public class BindBlobToMultipartFormTest { HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost:8001").build(); binder.bindToRequest(request, TEST_BLOB); - assertEquals(Strings2.toStringAndClose(request.getPayload().getInput()), EXPECTS); + assertEquals(Strings2.toString(request.getPayload()), EXPECTS); assertEquals(request.getPayload().getContentMetadata().getContentLength(), new Long(113)); assertEquals(request.getPayload().getContentMetadata().getContentType(), "multipart/form-data; boundary=" diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java index 9b9a1402af..200f4399b6 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java @@ -67,7 +67,7 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest { assertConsistencyAwareContainerSize(container, 1); HttpRequest request = view.getSigner().signGetBlob(container, name); assertEquals(request.getFilters().size(), 0); - assertEquals(Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().getInput()), text); + assertEquals(Strings2.toString(view.utils().http().invoke(request).getPayload()), text); } finally { returnContainer(container); } @@ -85,7 +85,7 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest { assertConsistencyAwareContainerSize(container, 1); HttpRequest request = view.getSigner().signGetBlob(container, name, range(0, 1)); assertEquals(request.getFilters().size(), 0); - assertEquals(Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().getInput()), "fo"); + assertEquals(Strings2.toString(view.utils().http().invoke(request).getPayload()), "fo"); } finally { returnContainer(container); } @@ -101,7 +101,7 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest { try { HttpRequest request = view.getSigner().signPutBlob(container, blob); assertEquals(request.getFilters().size(), 0); - Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().getInput()); + Strings2.toString(view.utils().http().invoke(request).getPayload()); assertConsistencyAwareContainerSize(container, 1); } finally { returnContainer(container); diff --git a/common/aws/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java b/common/aws/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java index 615801b439..fa4b7da7e5 100644 --- a/common/aws/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java +++ b/common/aws/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java @@ -81,7 +81,7 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler { } } else { try { - message = Strings2.toStringAndClose(response.getPayload().getInput()); + message = Strings2.toString(response.getPayload()); exception = new HttpResponseException(command, response, message); } catch (IOException e) { } diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java b/common/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java index 017d29356a..cdfb46bfe9 100644 --- a/common/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java +++ b/common/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java @@ -76,14 +76,14 @@ public class ParseAzureStorageErrorFromXmlContent implements HttpErrorHandler { } } catch (RuntimeException e) { try { - message = Strings2.toStringAndClose(response.getPayload().getInput()); + message = Strings2.toString(response.getPayload()); exception = new HttpResponseException(command, response, message); } catch (IOException e1) { } } } else { try { - message = Strings2.toStringAndClose(response.getPayload().getInput()); + message = Strings2.toString(response.getPayload()); exception = new HttpResponseException(command, response, message); } catch (IOException e) { } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java index bfacd23066..ae8c3bc48e 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponse.java @@ -101,7 +101,7 @@ public class ParseTerremarkVCloudErrorFromHttpResponse implements HttpErrorHandl String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { if (response.getPayload() != null) { try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { logger.warn(e, "exception reading error from response", response); } diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java index 6fab8fc46e..b8e71c6a82 100644 --- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java @@ -422,7 +422,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes return actual == null; } try { - String real = Strings2.toStringAndClose(((Payload) actual).getInput()); + String real = Strings2.toString(((Payload) actual)); assertEquals(real, expected); return true; } catch (IOException e) { diff --git a/core/src/main/java/org/jclouds/http/HttpResponseException.java b/core/src/main/java/org/jclouds/http/HttpResponseException.java index b1e03d4d03..f717a6f16d 100644 --- a/core/src/main/java/org/jclouds/http/HttpResponseException.java +++ b/core/src/main/java/org/jclouds/http/HttpResponseException.java @@ -88,7 +88,7 @@ public class HttpResponseException extends RuntimeException { && request.getPayload().getContentMetadata().getContentLength() < 1024) { try { return String.format(" [%s] ", request.getPayload() instanceof StringPayload ? request.getPayload() - .getRawContent() : Strings2.toStringAndClose(request.getPayload().getInput())); + .getRawContent() : Strings2.toString(request.getPayload())); } catch (IOException e) { } } diff --git a/core/src/main/java/org/jclouds/http/functions/ParseURIFromListOrLocationHeaderIf20x.java b/core/src/main/java/org/jclouds/http/functions/ParseURIFromListOrLocationHeaderIf20x.java index 64199b44c4..de47f00a68 100644 --- a/core/src/main/java/org/jclouds/http/functions/ParseURIFromListOrLocationHeaderIf20x.java +++ b/core/src/main/java/org/jclouds/http/functions/ParseURIFromListOrLocationHeaderIf20x.java @@ -61,7 +61,7 @@ public class ParseURIFromListOrLocationHeaderIf20x implements Function supplier) + throws IOException { + return CharStreams.toString(CharStreams.newReaderSupplier(supplier, + Charsets.UTF_8)); + } + public static String toStringAndClose(InputStream input) throws IOException { checkNotNull(input, "input"); try { diff --git a/core/src/test/java/org/jclouds/io/payloads/MultipartFormTest.java b/core/src/test/java/org/jclouds/io/payloads/MultipartFormTest.java index 71e3f11436..91608ab148 100644 --- a/core/src/test/java/org/jclouds/io/payloads/MultipartFormTest.java +++ b/core/src/test/java/org/jclouds/io/payloads/MultipartFormTest.java @@ -54,7 +54,7 @@ public class MultipartFormTest { MultipartForm multipartForm = new MultipartForm(boundary, newPart("hello")); - assertEquals(Strings2.toStringAndClose(multipartForm.getInput()), expects); + assertEquals(Strings2.toString(multipartForm), expects); assertEquals(multipartForm.getContentMetadata().getContentLength(), new Long(199)); } @@ -119,11 +119,11 @@ public class MultipartFormTest { MultipartForm multipartForm = new MultipartForm(boundary, newPart("hello"), newPart("goodbye")); - assertEquals(Strings2.toStringAndClose(multipartForm.getInput()), expects); + assertEquals(Strings2.toString(multipartForm), expects); // test repeatable assert multipartForm.isRepeatable(); - assertEquals(Strings2.toStringAndClose(multipartForm.getInput()), expects); + assertEquals(Strings2.toString(multipartForm), expects); assertEquals(multipartForm.getContentMetadata().getContentLength(), new Long(352)); } diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiExpectTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiExpectTest.java index b1ad1f0eab..67afbf7606 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiExpectTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiExpectTest.java @@ -386,8 +386,8 @@ public abstract class BaseRestApiExpectTest { switch (compareHttpRequestAsType(a)) { case XML: { - Diff diff = XMLUnit.compareXML(Strings2.toStringAndClose(a.getPayload().getInput()), Strings2 - .toStringAndClose(b.getPayload().getInput())); + Diff diff = XMLUnit.compareXML(Strings2.toString(a.getPayload()), Strings2 + .toString(b.getPayload())); // Ignoring whitespace in elements that have other children, xsi:schemaLocation and // differences in namespace prefixes @@ -419,8 +419,8 @@ public abstract class BaseRestApiExpectTest { } case JSON: { JsonParser parser = new JsonParser(); - JsonElement payloadA = parser.parse(Strings2.toStringAndClose(a.getPayload().getInput())); - JsonElement payloadB = parser.parse(Strings2.toStringAndClose(b.getPayload().getInput())); + JsonElement payloadA = parser.parse(Strings2.toString(a.getPayload())); + JsonElement payloadB = parser.parse(Strings2.toString(b.getPayload())); return Objects.equal(payloadA, payloadB); } default: { @@ -486,7 +486,7 @@ public abstract class BaseRestApiExpectTest { builder.append(header.getKey()).append(": ").append(header.getValue()).append('\n'); } try { - builder.append('\n').append(Strings2.toStringAndClose(request.getPayload().getInput())); + builder.append('\n').append(Strings2.toString(request.getPayload())); } catch (IOException e) { throw Throwables.propagate(e); } diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java index ed363f52c1..4c67b8aa8e 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java @@ -107,7 +107,7 @@ public abstract class BaseRestApiTest { } else { String payload = null; try { - payload = Strings2.toStringAndClose(request.getPayload().getInput()); + payload = Strings2.toString(request.getPayload()); } catch (IOException e) { propagate(e); } diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatus.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatus.java index 2a6ea0a69c..0163a1a5c4 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatus.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatus.java @@ -59,7 +59,7 @@ public class KeyToStoredTweetStatus implements Function= 0 : "no root in " + contents; } diff --git a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java index f0d78dd3c7..9ed1e06e3c 100644 --- a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java +++ b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java @@ -152,13 +152,13 @@ public class SshjSshClientLiveTest { SshClient client = setupClient(); client.put(temp.getAbsolutePath(), Payloads.newStringPayload("rabbit")); Payload input = client.get(temp.getAbsolutePath()); - String contents = Strings2.toStringAndClose(input.getInput()); + String contents = Strings2.toString(input); assertEquals(contents, "rabbit"); } public void testGetEtcPassword() throws IOException { Payload input = setupClient().get("/etc/passwd"); - String contents = Strings2.toStringAndClose(input.getInput()); + String contents = Strings2.toString(input); assert contents.indexOf("root") >= 0 : "no root in " + contents; } diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/handlers/GleSYSErrorHandler.java b/labs/glesys/src/main/java/org/jclouds/glesys/handlers/GleSYSErrorHandler.java index 9f5a37c309..82afc0fc17 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/handlers/GleSYSErrorHandler.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/handlers/GleSYSErrorHandler.java @@ -80,7 +80,7 @@ public class GleSYSErrorHandler implements HttpErrorHandler { if (response.getPayload() == null) return null; try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { throw new RuntimeException(e); } finally { diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java index 0c05f5cb43..5186b00196 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java @@ -84,7 +84,7 @@ public class VPDCErrorHandler implements HttpErrorHandler { if (response.getPayload() == null) return null; try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { throw new RuntimeException(e); } finally { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java index 3153f163ad..b7d66ea118 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java @@ -83,7 +83,7 @@ public class HttpClientLiveTest extends BaseVCloudDirectorApiLiveTest { assertTrue(sessionWithToken.getSession().getLinks().size() > 0); assertNotNull(sessionWithToken.getToken()); - OrgList orgList = parser.fromXML(Strings2.toStringAndClose(response.getPayload().getInput()), OrgList.class); + OrgList orgList = parser.fromXML(Strings2.toString(response.getPayload()), OrgList.class); assertTrue(orgList.getOrgs().size() > 0, "must have orgs"); @@ -99,7 +99,7 @@ public class HttpClientLiveTest extends BaseVCloudDirectorApiLiveTest { .addHeader("x-vcloud-authorization", sessionWithToken.getToken()) .addHeader("Accept", "*/*").build()); - String schema = Strings2.toStringAndClose(response.getPayload().getInput()); + String schema = Strings2.toString(response.getPayload()); // TODO: asserting something about the schema } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java index 0c1dc5fb31..7ac91bdd9c 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java @@ -265,7 +265,7 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { // Test GET of object (including updated metadata) AzureBlob getBlob = getApi().getBlob(privateContainer, object.getProperties().getName()); - assertEquals(Strings2.toStringAndClose(getBlob.getPayload().getInput()), data); + assertEquals(Strings2.toString(getBlob.getPayload()), data); // TODO assertEquals(getBlob.getName(), object.getProperties().getName()); assertEquals(getBlob.getPayload().getContentMetadata().getContentLength(), new Long(data.length())); assertEquals(getBlob.getProperties().getContentMetadata().getContentType(), "text/plain"); 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 acaf21e697..d013eb6b4e 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 @@ -118,7 +118,7 @@ public class ParseSlicehostErrorFromHttpResponse implements HttpErrorHandler { // slicehost returns " " which is unparsable if (response.getPayload() != null) { try { - String payload = Strings2.toStringAndClose(response.getPayload().getInput()).trim(); + String payload = Strings2.toString(response.getPayload()).trim(); return payload.indexOf("xml") != -1 ? errorParser.parse(payload) : payload; } catch (IOException e) { } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java index d67d41aedc..a8d8254a87 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java @@ -80,7 +80,7 @@ public class SoftLayerErrorHandler implements HttpErrorHandler { if (response.getPayload() == null) return null; try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { throw new RuntimeException(e); } finally { diff --git a/sandbox-providers/boxdotnet/src/main/java/org/jclouds/boxdotnet/handlers/BoxDotNetErrorHandler.java b/sandbox-providers/boxdotnet/src/main/java/org/jclouds/boxdotnet/handlers/BoxDotNetErrorHandler.java index aaf448401f..e6e90a0f22 100644 --- a/sandbox-providers/boxdotnet/src/main/java/org/jclouds/boxdotnet/handlers/BoxDotNetErrorHandler.java +++ b/sandbox-providers/boxdotnet/src/main/java/org/jclouds/boxdotnet/handlers/BoxDotNetErrorHandler.java @@ -76,7 +76,7 @@ public class BoxDotNetErrorHandler implements HttpErrorHandler { if (response.getPayload() == null) return null; try { - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } catch (IOException e) { throw new RuntimeException(e); } finally { diff --git a/sandbox-providers/ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/handlers/IBMSmartCloudErrorHandler.java b/sandbox-providers/ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/handlers/IBMSmartCloudErrorHandler.java index 93e5884606..b95416f6db 100644 --- a/sandbox-providers/ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/handlers/IBMSmartCloudErrorHandler.java +++ b/sandbox-providers/ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/handlers/IBMSmartCloudErrorHandler.java @@ -86,6 +86,6 @@ public class IBMSmartCloudErrorHandler implements HttpErrorHandler { public String parseMessage(HttpResponse response) throws IOException { if (response.getPayload() == null) return null; - return Strings2.toStringAndClose(response.getPayload().getInput()); + return Strings2.toString(response.getPayload()); } }