src/java.base/share/classes/sun/nio/ch/SelectorImpl.java
changeset 58496 7f34de3cdfe9
parent 58439 b25362cec8ce
child 58679 9c3209ff7550
equal deleted inserted replaced
58493:55a8d95c7787 58496:7f34de3cdfe9
   206                                           Object attachment)
   206                                           Object attachment)
   207     {
   207     {
   208         if (!(ch instanceof SelChImpl))
   208         if (!(ch instanceof SelChImpl))
   209             throw new IllegalSelectorException();
   209             throw new IllegalSelectorException();
   210         SelectionKeyImpl k = new SelectionKeyImpl((SelChImpl)ch, this);
   210         SelectionKeyImpl k = new SelectionKeyImpl((SelChImpl)ch, this);
   211         k.attach(attachment);
   211         if (attachment != null)
       
   212             k.attach(attachment);
   212 
   213 
   213         // register (if needed) before adding to key set
   214         // register (if needed) before adding to key set
   214         implRegister(k);
   215         implRegister(k);
   215 
   216 
   216         // add to the selector's key set, removing it immediately if the selector
   217         // add to the selector's key set, removing it immediately if the selector