File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
src/main/java/com/dropbox/core/http Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -214,7 +214,7 @@ public OutputStream getBody() {
214214 PipedRequestBody pipedBody = new PipedRequestBody ();
215215 setBody (pipedBody );
216216
217- this .callback = new AsyncCallback ();
217+ this .callback = new AsyncCallback (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 public static final class AsyncCallback implements Callback {
291+ private PipedRequestBody body ;
291292 private IOException error ;
292293 private okhttp3 .Response response ;
293294
294- private AsyncCallback () {
295+ private AsyncCallback (PipedRequestBody body ) {
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 public synchronized void onFailure (Call call , IOException ex ) {
316318 this .error = ex ;
319+ this .body .close ();
317320 notifyAll ();
318321 }
319322
You can’t perform that action at this time.
0 commit comments