Skip to content

Commit 7853021

Browse files
committed
Merge pull request android-async-http#188 from sayadyan/issue_187
Catch exceptions if thread is interrupted (fixed issue android-async-http#187)
2 parents e0a1feb + d5a99cb commit 7853021

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/com/loopj/android/http/AsyncHttpRequest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,20 @@ public void run() {
7373

7474
private void makeRequest() throws IOException {
7575
if(!Thread.currentThread().isInterrupted()) {
76-
HttpResponse response = client.execute(request, context);
77-
if(!Thread.currentThread().isInterrupted()) {
78-
if(responseHandler != null) {
79-
responseHandler.sendResponseMessage(response);
80-
}
81-
} else{
82-
//TODO: should raise InterruptedException? this block is reached whenever the request is cancelled before its response is received
83-
}
76+
try {
77+
HttpResponse response = client.execute(request, context);
78+
if(!Thread.currentThread().isInterrupted()) {
79+
if(responseHandler != null) {
80+
responseHandler.sendResponseMessage(response);
81+
}
82+
} else{
83+
//TODO: should raise InterruptedException? this block is reached whenever the request is cancelled before its response is received
84+
}
85+
} catch (IOException e) {
86+
if(!Thread.currentThread().isInterrupted()) {
87+
throw e;
88+
}
89+
}
8490
}
8591
}
8692

0 commit comments

Comments
 (0)