--- old/src/java.corba/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java Tue Dec 22 19:07:51 2015 +++ new/src/java.corba/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java Tue Dec 22 19:07:51 2015 @@ -26,8 +26,10 @@ package com.sun.corba.se.impl.transport; import java.io.IOException; +import java.net.ServerSocket; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectableChannel; +import java.nio.channels.ServerSocketChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.util.ArrayList; @@ -36,6 +38,7 @@ import java.util.Iterator; import java.util.List; + import com.sun.corba.se.pept.broker.Broker; import com.sun.corba.se.pept.transport.Acceptor; import com.sun.corba.se.pept.transport.Connection; @@ -239,6 +242,8 @@ readerThread.close(); } + clearDeferredRegistrations(); + // Selector try { @@ -328,6 +333,51 @@ // Implementation. // + private void clearDeferredRegistrations() { + synchronized (deferredRegistrations) { + int deferredListSize = deferredRegistrations.size(); + if (orb.transportDebugFlag) { + dprint(".clearDeferredRegistrations:deferred list size == " + deferredListSize); + } + for (int i = 0; i < deferredListSize; i++) { + EventHandler eventHandler = + (EventHandler)deferredRegistrations.get(i); + if (orb.transportDebugFlag) { + dprint(".clearDeferredRegistrations: " + eventHandler); + } + SelectableChannel channel = eventHandler.getChannel(); + SelectionKey selectionKey = null; + + try { + if (orb.transportDebugFlag) { + dprint(".clearDeferredRegistrations:close channel == " + + channel); + dprint(".clearDeferredRegistrations:close channel class == " + + channel.getClass().getName()); + } + channel.close(); + if (channel instanceof ServerSocketChannel) { + dprint(".clearDeferredRegistrations:close ServerSocketCHannel == " + + channel); + ServerSocket ss = ((ServerSocketChannel) channel) + .socket(); + ss.close(); + selectionKey = eventHandler.getSelectionKey(); + if (selectionKey != null) { + selectionKey.cancel(); + selectionKey.attach(null); + } + } + } catch (IOException ioEx) { + if (orb.transportDebugFlag) { + dprint(".handleDeferredRegistrations: " + ioEx); + } + } + } + deferredRegistrations.clear(); + } + } + private synchronized boolean isClosed () { return closed;