Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4ce7dd6

Browse files
committed
Fix uploading in OKHttp3 hanging forever when internet is cut off.
1 parente66052f commit4ce7dd6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎src/main/java/com/dropbox/core/http/OkHttp3Requestor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public OutputStream getBody() {
214214
PipedRequestBodypipedBody =newPipedRequestBody();
215215
setBody(pipedBody);
216216

217-
this.callback =newAsyncCallback();
217+
this.callback =newAsyncCallback(pipedBody);
218218
this.call =client.newCall(request.build());
219219
// enqueue the call (async call execution). This allows us to provide streaming uploads.
220220
call.enqueue(callback);
@@ -288,10 +288,12 @@ public Response finish() throws IOException {
288288
}
289289

290290
publicstaticfinalclassAsyncCallbackimplementsCallback {
291+
privatePipedRequestBodybody;
291292
privateIOExceptionerror;
292293
privateokhttp3.Responseresponse;
293294

294-
privateAsyncCallback() {
295+
privateAsyncCallback(PipedRequestBodybody) {
296+
this.body =body;
295297
this.error =null;
296298
this.response =null;
297299
}
@@ -314,6 +316,7 @@ public synchronized okhttp3.Response getResponse() throws IOException {
314316
@Override
315317
publicsynchronizedvoidonFailure(Callcall,IOExceptionex) {
316318
this.error =ex;
319+
this.body.close();
317320
notifyAll();
318321
}
319322

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp