Source:
public void channelRead(ChannelHandlerContext ctx, Object m) throws Exception { if (this.handshakeState.failed()) { log.warn("channelRead: Handshake has failed. Dropping message - {}", m); return; } if (m instanceof CorfuMsg) { CorfuMsg msg = (CorfuMsg) m; if (this.handshakeState.completed()) { super.channelRead(ctx, msg); } else { log.debug("channelRead: Dropping message: {}", msg.getMsgType().name()); } return; } else if (!(m instanceof ResponseMsg)) { log.error("channelRead: Message received is not a CorfuMsg or ResponseMsg type. Message - {}", m); return; } ResponseMsg response = ((ResponseMsg) m); if (!response.getPayload().hasHandshakeResponse()) { log.warn("channelRead: Non-Handshake Response received. Message - {}", response); if (this.handshakeState.completed()) { super.channelRead(ctx, m); } return; } log.info("channelRead: Handshake Response received. Removing from pipeline.", READ_TIMEOUT_HANDLER); ctx.pipeline().remove(READ_TIMEOUT_HANDLER).handlerRemoved(ctx); HandshakeResponseMsg handshakeResponse = response.getPayload().getHandshakeResponse(); String corfuVersion = handshakeResponse.getCorfuVersion(); UUID serverId = getUUID(handshakeResponse.getServerId()); if (this.nodeId.equals(DEFAULT_UUID)) { log.info("channelRead: node id matching is not requested by client."); } else if (!this.nodeId.equals(serverId)) { log.error("channelRead: Handshake validation failed. Server node id mismatch."); log.debug("channelRead: Client opened socket to server instead, connected to: [{}]", this.nodeId, serverId); this.fireHandshakeFailed(ctx); return; } log.info("channelRead: Handshake succeeded. Server Corfu Version: [{}]", corfuVersion); messages.forEach(ctx::writeAndFlush); messages.clear(); requestMessages.forEach(ctx::writeAndFlush); requestMessages.clear(); log.info("channelRead: Removing handshake handler from pipeline."); ctx.pipeline().remove(this); this.fireHandshakeSucceeded(ctx); }

Target:
public void channelRead(ChannelHandlerContext ctx, Object m) throws Exception { if (this.handshakeState.failed()) { log.warn("channelRead: Dropping the message as the handshake was not completed. Message - {}", m); return; } if (m instanceof CorfuMsg) { CorfuMsg msg = (CorfuMsg) m; if (this.handshakeState.completed()) { super.channelRead(ctx, msg); } else { log.debug("channelRead: Dropping the message as the handshake " + "was not completed. Message - {}", msg.getMsgType().name()); } return; } else if (!(m instanceof ResponseMsg)) { log.error("channelRead: Message received is not a CorfuMsg or ResponseMsg type. Message - {}", m); return; } ResponseMsg response = ((ResponseMsg) m); if (!response.getPayload().hasHandshakeResponse()) { log.warn("channelRead: Non-Handshake Response received. Message - {}", response); if (this.handshakeState.completed()) { super.channelRead(ctx, m); } return; } log.info("channelRead: Handshake Response received. Removing from pipeline.", READ_TIMEOUT_HANDLER); ctx.pipeline().remove(READ_TIMEOUT_HANDLER).handlerRemoved(ctx); HandshakeResponseMsg handshakeResponse = response.getPayload().getHandshakeResponse(); String corfuVersion = handshakeResponse.getCorfuVersion(); UUID serverId = getUUID(handshakeResponse.getServerId()); if (this.nodeId.equals(DEFAULT_UUID)) { log.info("channelRead: node id matching is not requested by client."); } else if (!this.nodeId.equals(serverId)) { log.error("channelRead: Handshake validation failed. Server node id mismatch."); log.debug("channelRead: Client opened socket to server instead, connected to: [{}]", this.nodeId, serverId); this.fireHandshakeFailed(ctx); return; } log.info("channelRead: Handshake succeeded. Server Corfu Version: [{}]", corfuVersion); messages.forEach(ctx::writeAndFlush); messages.clear(); requestMessages.forEach(ctx::writeAndFlush); requestMessages.clear(); log.info("channelRead: Removing handshake handler from pipeline."); ctx.pipeline().remove(this); this.fireHandshakeSucceeded(ctx); }