From 4594b728b045ecfda80cb1dc905b2055284d7634 Mon Sep 17 00:00:00 2001 From: sherman Date: Fri, 27 Jun 2008 08:32:30 -0700 Subject: [PATCH] 6645197: (so) Timed read with socket adaptor throws ClosedSelectorException if temporary selector GC'ed Summary: Temporary selector for timeout is not protected from possilbe GC when used first time Reviewed-by: alanb --- src/share/classes/sun/nio/ch/Util.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/share/classes/sun/nio/ch/Util.java b/src/share/classes/sun/nio/ch/Util.java index 73b66e072..da9c3344c 100644 --- a/src/share/classes/sun/nio/ch/Util.java +++ b/src/share/classes/sun/nio/ch/Util.java @@ -142,11 +142,10 @@ class Util { || ((sel = selWrapper.get()) == null) || (sel.provider() != sc.provider())) { sel = sc.provider().openSelector(); - localSelector.set(new SoftReference( - new SelectorWrapper(sel))); - } else { - localSelectorWrapper.set(selWrapper); + selWrapper = new SelectorWrapper(sel); + localSelector.set(new SoftReference(selWrapper)); } + localSelectorWrapper.set(selWrapper); return sel; } -- GitLab