Skip to content

Commit c65d6d1

Browse files
committed
Merge pull request android-async-http#595 from fineswap/strictness-javadoc
Fix Javadoc, Add @OverRide, Stricter exception handling.
2 parents 496e117 + 6fcdf0d commit c65d6d1

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

library/src/main/java/com/loopj/android/http/AsyncHttpClient.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,7 @@ public static String getUrlWithQueryString(boolean shouldEncodeUrl, String url,
11701170
*
11711171
* @param inputStream InputStream to be checked
11721172
* @return true or false if the stream contains GZIP compressed data
1173+
* @throws java.io.IOException
11731174
*/
11741175
public static boolean isInputStreamGZIPCompressed(final PushbackInputStream inputStream) throws IOException {
11751176
if (inputStream == null)
@@ -1226,11 +1227,11 @@ private HttpEntity paramsToEntity(RequestParams params, ResponseHandlerInterface
12261227
if (params != null) {
12271228
entity = params.getEntity(responseHandler);
12281229
}
1229-
} catch (Throwable t) {
1230+
} catch (IOException e) {
12301231
if (responseHandler != null)
1231-
responseHandler.sendFailureMessage(0, null, null, t);
1232+
responseHandler.sendFailureMessage(0, null, null, e);
12321233
else
1233-
t.printStackTrace();
1234+
e.printStackTrace();
12341235
}
12351236

12361237
return entity;

library/src/main/java/com/loopj/android/http/FileAsyncHttpResponseHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ protected File getTemporaryFile(Context context) {
7474
assert (context != null);
7575
try {
7676
return File.createTempFile("temp_", "_handled", context.getCacheDir());
77-
} catch (Throwable t) {
78-
Log.e(LOG_TAG, "Cannot create temporary file", t);
77+
} catch (IOException e) {
78+
Log.e(LOG_TAG, "Cannot create temporary file", e);
7979
}
8080
return null;
8181
}

library/src/main/java/com/loopj/android/http/MyRedirectHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public MyRedirectHandler(final boolean allowRedirects) {
5252
this.enableRedirects = allowRedirects;
5353
}
5454

55+
@Override
5556
public boolean isRedirectRequested(
5657
final HttpResponse response,
5758
final HttpContext context) {
@@ -73,6 +74,7 @@ public boolean isRedirectRequested(
7374
} //end of switch
7475
}
7576

77+
@Override
7678
public URI getLocationURI(
7779
final HttpResponse response,
7880
final HttpContext context) throws ProtocolException {

library/src/main/java/com/loopj/android/http/PersistentCookieStore.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
import java.io.ByteArrayOutputStream;
3131
import java.io.ObjectInputStream;
3232
import java.io.ObjectOutputStream;
33+
34+
import java.io.IOException;
35+
3336
import java.util.ArrayList;
3437
import java.util.Date;
3538
import java.util.List;
@@ -185,7 +188,8 @@ protected String encodeCookie(SerializableCookie cookie) {
185188
try {
186189
ObjectOutputStream outputStream = new ObjectOutputStream(os);
187190
outputStream.writeObject(cookie);
188-
} catch (Exception e) {
191+
} catch (IOException e) {
192+
Log.d(LOG_TAG, "IOException in encodeCookie", e);
189193
return null;
190194
}
191195

@@ -205,8 +209,10 @@ protected Cookie decodeCookie(String cookieString) {
205209
try {
206210
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
207211
cookie = ((SerializableCookie) objectInputStream.readObject()).getCookie();
208-
} catch (Exception exception) {
209-
Log.d(LOG_TAG, "decodeCookie failed", exception);
212+
} catch (IOException e) {
213+
Log.d(LOG_TAG, "IOException in decodeCookie", e);
214+
} catch (ClassNotFoundException e) {
215+
Log.d(LOG_TAG, "ClassNotFoundException in decodeCookie", e);
210216
}
211217

212218
return cookie;

library/src/main/java/com/loopj/android/http/SaxAsyncHttpResponseHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
* });
5555
* <pre/>
5656
*
57+
* @param <T> Handler extending {@link org.xml.sax.helpers.DefaultHandler}
5758
* @see org.xml.sax.helpers.DefaultHandler
5859
* @see com.loopj.android.http.AsyncHttpResponseHandler
5960
*/
@@ -83,6 +84,8 @@ public SaxAsyncHttpResponseHandler(T t) {
8384
* Deconstructs response into given content handler
8485
*
8586
* @param entity returned HttpEntity
87+
* @return deconstructed response
88+
* @throws java.io.IOException
8689
* @see org.apache.http.HttpEntity
8790
*/
8891
@Override

0 commit comments

Comments
 (0)