changeset 391:496cb56af58d

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
author sherman
date Fri, 27 Jun 2008 08:32:30 -0700
parents b212b96b3919
children d20c51803e8b
files src/share/classes/sun/nio/ch/Util.java
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/nio/ch/Util.java	Wed Jun 25 13:58:22 2008 -0700
+++ b/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;
     }