summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Hudson <nick.hudson@isode.com>2015-01-13 12:02:06 (GMT)
committerNick Hudson <nick.hudson@isode.com>2015-01-13 17:02:53 (GMT)
commitad96cd3f5f8c07ad6569cbb4863c782ba0920d3d (patch)
tree16a6196ce339eb3dd0329fc6b276b98480c32e83
parente327b17aa54430284e67af3accf90f45430f74d6 (diff)
downloadstroke-ad96cd3f5f8c07ad6569cbb4863c782ba0920d3d.zip
stroke-ad96cd3f5f8c07ad6569cbb4863c782ba0920d3d.tar.bz2
Don't call wakeup on closed selectors
This operation should be valid according to Javadocs, but triggers a crash on Android Lollipop: https://code.google.com/p/android/issues/detail?id=80785 This workaround avoids the crash, and should not affect behaviour for all other versions. Test-information: Forced disconnect on Lollipop, didn't see crash. Tested MLC with deliberately dropped connections; seems to work as expected. Change-Id: Ia08476266dd92c40bea04076b3c3d8750737c309 Reviewer: Nick Hudson <nick.hudson@isode.com>
-rw-r--r--src/com/isode/stroke/network/JavaConnection.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/com/isode/stroke/network/JavaConnection.java b/src/com/isode/stroke/network/JavaConnection.java
index 46f43ab..f1d72bb 100644
--- a/src/com/isode/stroke/network/JavaConnection.java
+++ b/src/com/isode/stroke/network/JavaConnection.java
@@ -3,7 +3,7 @@
* All rights reserved.
*/
/*
- * Copyright (c) 2010-2013, Isode Limited, London, England.
+ * Copyright (c) 2010-2015, Isode Limited, London, England.
* All rights reserved.
*/
package com.isode.stroke.network;
@@ -340,7 +340,9 @@ public class JavaConnection extends Connection implements EventOwner {
@Override
public void disconnect() {
disconnecting_ = true;
- if (selector_ != null) {
+ // Check "isOpen" to Avoid Android crash see
+ // https://code.google.com/p/android/issues/detail?id=80785
+ if (selector_ != null && selector_.isOpen()) {
selector_.wakeup();
}
}
@@ -348,7 +350,9 @@ public class JavaConnection extends Connection implements EventOwner {
@Override
public void write(ByteArray data) {
worker_.writeBuffer_.add(data.getData());
- if (selector_ != null) {
+ // Check "isOpen" to Avoid Android crash see
+ // https://code.google.com/p/android/issues/detail?id=80785
+ if (selector_ != null && selector_.isOpen()) {
selector_.wakeup();
}