protected Object doCall() throws Exception { IOEvent ioEvent = context.getIOEvent(); OpType currentOpType = context.getCurrentOpType(); try { if (currentOpType == OpType.OP_READ) { callBackHandler.onRead(ioEvent); } else if (currentOpType == OpType.OP_WRITE) { callBackHandler.onWrite(ioEvent); } else if (currentOpType == OpType.OP_CONNECT) { callBackHandler.onConnect(ioEvent); } } finally { if (ioEvent != null) { // Prevent the CallbackHandler to re-use the context. // TODO: This is still dangerous as the Context might have been // cached by the CallbackHandler. ioEvent.attach(null); ioEvent = null; } } return null; }