28
28
29
29
import java .io .IOException ;
30
30
import java .net .ConnectException ;
31
+ import java .net .MalformedURLException ;
31
32
import java .net .SocketException ;
32
33
import java .net .SocketTimeoutException ;
33
34
import java .net .UnknownHostException ;
@@ -74,16 +75,19 @@ public void run() {
74
75
}
75
76
}
76
77
77
- private void makeRequest () throws IOException {
78
+ private void makeRequest () throws IOException , InterruptedException {
78
79
if (!Thread .currentThread ().isInterrupted ()) {
79
80
try {
81
+ // Fixes #115
82
+ if (request .getURI ().getScheme () == null )
83
+ throw new MalformedURLException ("No valid URI scheme was provided" );
80
84
HttpResponse response = client .execute (request , context );
81
85
if (!Thread .currentThread ().isInterrupted ()) {
82
86
if (responseHandler != null ) {
83
87
responseHandler .sendResponseMessage (response );
84
88
}
85
89
} else {
86
- //TODO: should raise InterruptedException? this block is reached whenever the request is cancelled before its response is received
90
+ throw new InterruptedException ( "makeRequest was interrupted" );
87
91
}
88
92
} catch (IOException e ) {
89
93
if (!Thread .currentThread ().isInterrupted ()) {
@@ -104,7 +108,7 @@ private void makeRequestWithRetries() throws ConnectException {
104
108
makeRequest ();
105
109
return ;
106
110
} catch (ClientProtocolException e ) {
107
- if (responseHandler != null ) {
111
+ if (responseHandler != null ) {
108
112
responseHandler .sendFailureMessage (e , "cannot repeat the request" );
109
113
}
110
114
return ;
@@ -137,6 +141,9 @@ private void makeRequestWithRetries() throws ConnectException {
137
141
// http://code.google.com/p/android/issues/detail?id=5255
138
142
cause = new IOException ("NPE in HttpClient" + e .getMessage ());
139
143
retry = retryHandler .retryRequest (cause , ++executionCount , context );
144
+ } catch (InterruptedException e ) {
145
+ cause = new IOException ("Request was interrupted while executing" );
146
+ retry = retryHandler .retryRequest (cause , ++executionCount , context );
140
147
}
141
148
}
142
149
0 commit comments