From 34e195e8e2db1de0b71460afcce2417d34fc7717 Mon Sep 17 00:00:00 2001 From: Gurmeen Bindra Date: Mon, 12 Aug 2013 09:58:52 +0100 Subject: Null check for selector before trying to close it It is possible to have a null selector if socketchannel open failed so adding a null check in this patch. Test-information: sanity tested on linux by connecting/reconnecting on an xmpp service on linux Change-Id: Idee180ca4aefd1f743705da674b486dd8acc4922 Reviewer: Nick Hudson Reviewer: Kevin Smith diff --git a/src/com/isode/stroke/network/JavaConnection.java b/src/com/isode/stroke/network/JavaConnection.java index 2069e33..31b07a0 100644 --- a/src/com/isode/stroke/network/JavaConnection.java +++ b/src/com/isode/stroke/network/JavaConnection.java @@ -131,11 +131,16 @@ public class JavaConnection extends Connection implements EventOwner { } finally { if(socketChannel_ != null) { try { - socketChannel_.close(); - selector_.close(); + socketChannel_.close(); } catch (IOException ex) { /* Do we need to return an error if we're already trying to close? */ } + if(selector_ != null) { + try { + selector_.close(); + } catch (IOException e) { + } + } } } } -- cgit v0.10.2-6-g49f6