aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoushik Dutta <koushd@gmail.com>2014-01-18 20:03:29 -0800
committerKoushik Dutta <koushd@gmail.com>2014-01-18 20:03:29 -0800
commitddd14033524fdc24d92b572cbad0836083da763a (patch)
treeb1c62bc3732f32257657200556c138228c35baee
parent8ff596ddc80350760ba6c14cf6adad35fe5fd368 (diff)
downloadAndroidAsync-ddd14033524fdc24d92b572cbad0836083da763a.tar.gz
AndroidAsync-ddd14033524fdc24d92b572cbad0836083da763a.tar.bz2
AndroidAsync-ddd14033524fdc24d92b572cbad0836083da763a.zip
Catch cancelled key exceptions.
Eat data on http client connect cancellation. Add keySet method for HashedList. Change-Id: I7a15d1e8ecdd58c3b853c7d51ea17574da7d7102
-rw-r--r--AndroidAsync/src/com/koushikdutta/async/AsyncServer.java5
-rw-r--r--AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java4
-rw-r--r--AndroidAsync/src/com/koushikdutta/async/util/HashList.java5
3 files changed, 12 insertions, 2 deletions
diff --git a/AndroidAsync/src/com/koushikdutta/async/AsyncServer.java b/AndroidAsync/src/com/koushikdutta/async/AsyncServer.java
index cdfa8c9..6fb0336 100644
--- a/AndroidAsync/src/com/koushikdutta/async/AsyncServer.java
+++ b/AndroidAsync/src/com/koushikdutta/async/AsyncServer.java
@@ -18,6 +18,7 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
+import java.nio.channels.CancelledKeyException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.DatagramChannel;
@@ -576,7 +577,7 @@ public class AsyncServer {
}
catch (Exception e) {
Log.e(LOGTAG, "exception?", e);
- }
+ }
return;
}
@@ -764,6 +765,8 @@ public class AsyncServer {
assert false;
}
}
+ catch (CancelledKeyException ex) {
+ }
catch (Exception ex) {
Log.e(LOGTAG, "inner loop exception", ex);
}
diff --git a/AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java b/AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java
index f18adf9..37a8372 100644
--- a/AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java
+++ b/AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java
@@ -93,8 +93,10 @@ public class AsyncHttpClient {
if (!super.cancel())
return false;
- if (socket != null)
+ if (socket != null) {
+ socket.setDataCallback(new NullDataCallback());
socket.close();
+ }
if (scheduled != null)
mServer.removeAllCallbacks(scheduled);
diff --git a/AndroidAsync/src/com/koushikdutta/async/util/HashList.java b/AndroidAsync/src/com/koushikdutta/async/util/HashList.java
index 7ea19a8..9fd41b6 100644
--- a/AndroidAsync/src/com/koushikdutta/async/util/HashList.java
+++ b/AndroidAsync/src/com/koushikdutta/async/util/HashList.java
@@ -2,6 +2,7 @@ package com.koushikdutta.async.util;
import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.Set;
/**
* Created by koush on 5/27/13.
@@ -15,6 +16,10 @@ public class HashList<T> {
public HashList() {
}
+ public Set<String> keySet() {
+ return internal.keySet();
+ }
+
public synchronized <V> V tag(String key) {
TaggedList<T> list = internal.get(key);
if (list == null)