6645197: (so) Timed read with socket adaptor throws ClosedSelectorException if temporary selector GC'ed
authorsherman
Fri, 27 Jun 2008 08:32:30 -0700
changeset 787 637b139ce684
parent 785 36c29b2692f1
child 788 543f9917b10a
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
jdk/src/share/classes/sun/nio/ch/Util.java
--- a/jdk/src/share/classes/sun/nio/ch/Util.java	Wed Jun 25 13:58:22 2008 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/Util.java	Fri Jun 27 08:32:30 2008 -0700
@@ -142,11 +142,10 @@
             || ((sel = selWrapper.get()) == null)
             || (sel.provider() != sc.provider())) {
             sel = sc.provider().openSelector();
-            localSelector.set(new SoftReference<SelectorWrapper>(
-                                  new SelectorWrapper(sel)));
-        } else {
-            localSelectorWrapper.set(selWrapper);
+            selWrapper = new SelectorWrapper(sel);
+            localSelector.set(new SoftReference<SelectorWrapper>(selWrapper));
         }
+        localSelectorWrapper.set(selWrapper);
         return sel;
     }