@Override public void finalize() throws Throwable { try { try { disconnect(); } catch (Exception e) { /* Ignore */ } try { selector.close(); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Failed to close selector", e); } } super.finalize(); } catch (Exception excp) { excp.printStackTrace(); } }
public void sendMessage(Member[] destination, ChannelMessage message) throws ChannelException { if (!connected) throw new ChannelException("Sender not connected."); ParallelNioSender sender = (ParallelNioSender) getSender(); if (sender == null) { ChannelException cx = new ChannelException("Unable to retrieve a data sender, time out error."); for (int i = 0; i < destination.length; i++) cx.addFaultyMember( destination[i], new NullPointerException("Unable to retrieve a sender from the sender pool")); throw cx; } else { try { sender.sendMessage(destination, message); sender.keepalive(); } catch (ChannelException x) { sender.disconnect(); throw x; } finally { returnSender(sender); if (!connected) disconnect(); } } }