Skip to content

Commit 7305989

Browse files
committed
Fix the bug that when InputStream throws IOException, DbxUploader#uploadAndFinish() throws NetworkIOException
1 parent 6ba8d5a commit 7305989

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/main/java/com/dropbox/core/DbxUploader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public R uploadAndFinish(InputStream in) throws X, DbxException, IOException {
9393
try {
9494
try {
9595
httpUploader.upload(in);
96+
} catch (IOUtil.ReadException ex) {
97+
throw ex.getCause();
9698
} catch (IOException ex) {
9799
// write exceptions and everything else is a Network I/O problem
98100
throw new NetworkIOException(ex);

src/main/java/com/dropbox/core/http/HttpRequestor.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ public static abstract class Uploader {
7979
public abstract Response finish() throws IOException;
8080

8181
public void upload(File file) throws IOException {
82-
upload(new FileInputStream(file));
82+
try {
83+
upload(new FileInputStream(file));
84+
} catch (IOUtil.ReadException ex) {
85+
throw ex.getCause();
86+
} catch (IOUtil.WriteException ex) {
87+
throw ex.getCause();
88+
}
8389
}
8490

8591
public void upload(InputStream in, long limit) throws IOException {
@@ -90,8 +96,6 @@ public void upload(InputStream in) throws IOException {
9096
OutputStream out = getBody();
9197
try {
9298
IOUtil.copyStreamToStream(in, out);
93-
} catch (IOUtil.ReadException ex) {
94-
throw ex.getCause();
9599
} finally {
96100
out.close();
97101
}

0 commit comments

Comments
 (0)