diff options
author | Koushik Dutta <koushd@gmail.com> | 2013-12-14 11:18:04 -0800 |
---|---|---|
committer | Koushik Dutta <koushd@gmail.com> | 2013-12-14 11:18:04 -0800 |
commit | e035e7c4527ef5e6228d3b3d2093b53f52094f07 (patch) | |
tree | 9fe3246eb7a4bd5beee7887c99f9cb675791bc7a | |
parent | 40fddd0d2fe36716427b76339cc9dd2067666cc3 (diff) | |
download | AndroidAsync-e035e7c4527ef5e6228d3b3d2093b53f52094f07.tar.gz AndroidAsync-e035e7c4527ef5e6228d3b3d2093b53f52094f07.tar.bz2 AndroidAsync-e035e7c4527ef5e6228d3b3d2093b53f52094f07.zip |
Fix some NPE in AsyncHttpServerResponseImple.
-rw-r--r-- | AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerResponseImpl.java | 16 | ||||
-rw-r--r-- | AndroidAsync/src/com/koushikdutta/async/parser/DocumentParser.java | 2 |
2 files changed, 7 insertions, 11 deletions
diff --git a/AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerResponseImpl.java b/AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerResponseImpl.java index 8839f99..844ecf3 100644 --- a/AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerResponseImpl.java +++ b/AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerResponseImpl.java @@ -232,10 +232,6 @@ public class AsyncHttpServerResponseImpl implements AsyncHttpServerResponse { end = Integer.parseInt(parts[1]); else end = totalLength - 1; -// else if (start != 0) -// end = (int)file.length() - 1; -// else -// end = Math.min((int)file.length() - 1, 50000); responseCode(206); getHeaders().getHeaders().set("Content-Range", String.format("bytes %d-%d/%d", start, end, totalLength)); @@ -301,21 +297,23 @@ public class AsyncHttpServerResponseImpl implements AsyncHttpServerResponse { @Override public void onCompleted(Exception ex) { - if (ex != null) { - ex.printStackTrace(); - } end(); } @Override public boolean isOpen() { - return mSink.isOpen(); + if (mSink != null) + return mSink.isOpen(); + return mSocket.isOpen(); } @Override public void close() { end(); - mSink.close(); + if (mSink != null) + mSink.close(); + else + mSocket.close(); } @Override diff --git a/AndroidAsync/src/com/koushikdutta/async/parser/DocumentParser.java b/AndroidAsync/src/com/koushikdutta/async/parser/DocumentParser.java index a11783e..fe54e04 100644 --- a/AndroidAsync/src/com/koushikdutta/async/parser/DocumentParser.java +++ b/AndroidAsync/src/com/koushikdutta/async/parser/DocumentParser.java @@ -7,8 +7,6 @@ import com.koushikdutta.async.callback.CompletedCallback; import com.koushikdutta.async.future.Future; import com.koushikdutta.async.future.TransformFuture; import com.koushikdutta.async.http.body.DocumentBody; -import com.koushikdutta.async.parser.AsyncParser; -import com.koushikdutta.async.parser.ByteBufferListParser; import com.koushikdutta.async.stream.ByteBufferListInputStream; import org.w3c.dom.Document; |