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
--- 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;
}