From 807f2a8d514ae354ab176b13c92955edcb89833a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 30 Jan 2012 13:42:32 -0700 Subject: [PATCH] avoid crash when Selector.close is called more than once on the same instance --- classpath/java/nio/channels/SocketSelector.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/classpath/java/nio/channels/SocketSelector.java b/classpath/java/nio/channels/SocketSelector.java index 2482d0f180..2d5cdbd699 100644 --- a/classpath/java/nio/channels/SocketSelector.java +++ b/classpath/java/nio/channels/SocketSelector.java @@ -106,8 +106,11 @@ class SocketSelector extends Selector { return selectedKeys.size(); } - public void close() { - natClose(state); + public synchronized void close() { + if (isOpen()) { + natClose(state); + state = 0; + } } private static native long natInit();