Skip to content

Commit a12fd74

Browse files
committed
Fixed an error where a retry would cause an IOException: Channel Closed
1 parent 15b7335 commit a12fd74

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.spectralogic.ds3client;
2+
3+
4+
import org.apache.commons.io.IOUtils;
5+
import org.apache.http.entity.ContentType;
6+
import org.apache.http.entity.InputStreamEntity;
7+
8+
import java.io.IOException;
9+
import java.io.InputStream;
10+
import java.io.OutputStream;
11+
12+
public class Ds3InputStreamEntity extends InputStreamEntity{
13+
14+
public Ds3InputStreamEntity(final InputStream inStream, final long length, final ContentType contentType) {
15+
super(inStream, length, contentType);
16+
}
17+
18+
@Override
19+
public void writeTo(final OutputStream outStream) throws IOException {
20+
IOUtils.copy(this.getContent(), outStream);
21+
}
22+
}

src/main/java/com/spectralogic/ds3client/NetworkClientImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private HttpRequest buildHttpRequest() throws IOException {
125125
final String path = this.buildPath();
126126
if (this.content != null) {
127127
final BasicHttpEntityEnclosingRequest httpRequest = new BasicHttpEntityEnclosingRequest(verb, path);
128-
httpRequest.setEntity(new InputStreamEntity(this.content, this.ds3Request.getSize(), this.ds3Request.getContentType()));
128+
httpRequest.setEntity(new Ds3InputStreamEntity(this.content, this.ds3Request.getSize(), this.ds3Request.getContentType()));
129129
return httpRequest;
130130
} else {
131131
return new BasicHttpRequest(verb, path);

0 commit comments

Comments
 (0)