SimpleStringParser extends AbstractRedisClientProtocol<String> { @Override public RedisClientProtocol<String> read(ByteBuf byteBuf){ String data = readTilCRLFAsString(byteBuf); if(data == null){ return null; } int beginIndex = 0; int endIndex = data.length(); int dataLength = data.length(); if(data.charAt(0) == PLUS_BYTE){ beginIndex = 1; } if(data.charAt(dataLength - 2) == '\r' && data.charAt(dataLength - 1) == '\n'){ endIndex -= 2; } return new SimpleStringParser(data.substring(beginIndex, endIndex)); } SimpleStringParser();  SimpleStringParser(String payload);  SimpleStringParser(String payload, boolean logRead, boolean logWrite); @Override RedisClientProtocol<String> read(ByteBuf byteBuf); @Override boolean supportes(Class<?> clazz); static final byte[] OK; }
@Test public void testSplit(){ String[] contents = new String[]{ "+", "\r", randomString(), "\n", "\r\n", randomString() }; RedisClientProtocol<?> client = parse(simpleStringParser, contents); Assert.assertEquals(realContent(contents), client.getPayload()); client.read(Unpooled.wrappedBuffer("123456".getBytes())); Assert.assertEquals(realContent(contents), client.getPayload()); }