From 15b7335ac3e2a29f6d3b3b3a320ed75ac05cb24f Mon Sep 17 00:00:00 2001 From: Ryan Moore Date: Mon, 11 Aug 2014 12:49:31 -0600 Subject: [PATCH 1/3] Removed some unneeded code in the network retry code. --- .../com/spectralogic/ds3client/NetworkClientImpl.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/spectralogic/ds3client/NetworkClientImpl.java b/src/main/java/com/spectralogic/ds3client/NetworkClientImpl.java index cc512139c..80962b051 100644 --- a/src/main/java/com/spectralogic/ds3client/NetworkClientImpl.java +++ b/src/main/java/com/spectralogic/ds3client/NetworkClientImpl.java @@ -61,17 +61,16 @@ public ConnectionDetails getConnectionDetails() { @Override public WebResponse getResponse(final Ds3Request request) throws IOException, SignatureException { try (final RequestExecutor requestExecutor = new RequestExecutor(request)) { - boolean redirect = false; int redirectCount = 0; do { final CloseableHttpResponse response = requestExecutor.execute(); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_TEMPORARY_REDIRECT) { - redirect = true; redirectCount++; - continue; } - return new WebResponseImpl(response); - } while (redirect && redirectCount < this.connectionDetails.getRetries()); + else { + return new WebResponseImpl(response); + } + } while (redirectCount < this.connectionDetails.getRetries()); throw new TooManyRedirectsException(redirectCount); } From a12fd7409fd4adf4e39e7ccab62db868858e12bf Mon Sep 17 00:00:00 2001 From: Ryan Moore Date: Mon, 11 Aug 2014 15:45:22 -0600 Subject: [PATCH 2/3] Fixed an error where a retry would cause an IOException: Channel Closed --- .../ds3client/Ds3InputStreamEntity.java | 22 +++++++++++++++++++ .../ds3client/NetworkClientImpl.java | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/spectralogic/ds3client/Ds3InputStreamEntity.java diff --git a/src/main/java/com/spectralogic/ds3client/Ds3InputStreamEntity.java b/src/main/java/com/spectralogic/ds3client/Ds3InputStreamEntity.java new file mode 100644 index 000000000..33c1cbee0 --- /dev/null +++ b/src/main/java/com/spectralogic/ds3client/Ds3InputStreamEntity.java @@ -0,0 +1,22 @@ +package com.spectralogic.ds3client; + + +import org.apache.commons.io.IOUtils; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.InputStreamEntity; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +public class Ds3InputStreamEntity extends InputStreamEntity{ + + public Ds3InputStreamEntity(final InputStream inStream, final long length, final ContentType contentType) { + super(inStream, length, contentType); + } + + @Override + public void writeTo(final OutputStream outStream) throws IOException { + IOUtils.copy(this.getContent(), outStream); + } +} diff --git a/src/main/java/com/spectralogic/ds3client/NetworkClientImpl.java b/src/main/java/com/spectralogic/ds3client/NetworkClientImpl.java index 80962b051..28c8f865a 100644 --- a/src/main/java/com/spectralogic/ds3client/NetworkClientImpl.java +++ b/src/main/java/com/spectralogic/ds3client/NetworkClientImpl.java @@ -125,7 +125,7 @@ private HttpRequest buildHttpRequest() throws IOException { final String path = this.buildPath(); if (this.content != null) { final BasicHttpEntityEnclosingRequest httpRequest = new BasicHttpEntityEnclosingRequest(verb, path); - httpRequest.setEntity(new InputStreamEntity(this.content, this.ds3Request.getSize(), this.ds3Request.getContentType())); + httpRequest.setEntity(new Ds3InputStreamEntity(this.content, this.ds3Request.getSize(), this.ds3Request.getContentType())); return httpRequest; } else { return new BasicHttpRequest(verb, path); From 0f16e9c0416761b563200dba4558eb0e12e6caa0 Mon Sep 17 00:00:00 2001 From: Ryan Moore Date: Mon, 11 Aug 2014 15:47:42 -0600 Subject: [PATCH 3/3] Reving to v0.7.1 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 60a612a28..0a82ad6bd 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'maven' sourceCompatibility = JavaVersion.VERSION_1_7 jar.archiveName = 'ds3_java_sdk' -version = '0.7.0-SNAPSHOT' +version = '0.7.1-SNAPSHOT' group = 'com.spectralogic' install.dependsOn test //make sure that the tests get ran before attempting to install