X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=library%2Fimpl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fovsdb%2Flib%2Fjsonrpc%2FJsonRpcDecoder.java;fp=library%2Fimpl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fovsdb%2Flib%2Fjsonrpc%2FJsonRpcDecoder.java;h=6becb384e228769cdc1fa452b9c328f38f95ecba;hb=6063cba8904ffbe05f4f963d640f79392878a2f7;hp=3e82761821c7dab92c839fadd1492003a760560c;hpb=9ad72607d311b7c003611fa0a1cb6d2a15d15ae6;p=ovsdb.git diff --git a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcDecoder.java b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcDecoder.java index 3e8276182..6becb384e 100644 --- a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcDecoder.java +++ b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcDecoder.java @@ -38,12 +38,12 @@ import org.slf4j.LoggerFactory; * in the stream. */ public class JsonRpcDecoder extends ByteToMessageDecoder { - private static final Logger LOG = LoggerFactory.getLogger(JsonRpcDecoder.class); + private static final JsonFactory JSON_FACTORY = new MappingJsonFactory(); + private final int maxFrameLength; //Indicates if the frame limit warning was issued private boolean maxFrameLimitWasReached = false; - private final JsonFactory jacksonJsonFactory = new MappingJsonFactory(); private final IOContext jacksonIOContext = new IOContext(new BufferRecycler(), null, false); @@ -55,15 +55,15 @@ public class JsonRpcDecoder extends ByteToMessageDecoder { private int recordsRead; - public JsonRpcDecoder(int maxFrameLength) { + public JsonRpcDecoder(final int maxFrameLength) { this.maxFrameLength = maxFrameLength; } @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List out) throws Exception { - - LOG.trace("readable bytes {}, records read {}, incomplete record bytes {}", - buf.readableBytes(), recordsRead, lastRecordBytes); + protected void decode(final ChannelHandlerContext ctx, final ByteBuf buf, final List out) + throws IOException { + LOG.trace("readable bytes {}, records read {}, incomplete record bytes {}", buf.readableBytes(), + recordsRead, lastRecordBytes); if (lastRecordBytes == 0) { if (buf.readableBytes() < 4) { @@ -106,7 +106,7 @@ public class JsonRpcDecoder extends ByteToMessageDecoder { if (leftCurlies != 0 && leftCurlies == rightCurlies && !inS) { ByteBuf slice = buf.readSlice(1 + index - buf.readerIndex()); - JsonParser jp = jacksonJsonFactory.createParser((InputStream) new ByteBufInputStream(slice)); + JsonParser jp = JSON_FACTORY.createParser((InputStream) new ByteBufInputStream(slice)); JsonNode root = jp.readValueAsTree(); out.add(root); leftCurlies = 0; @@ -142,7 +142,7 @@ public class JsonRpcDecoder extends ByteToMessageDecoder { return recordsRead; } - private static void skipSpaces(ByteBuf byteBuf) throws IOException { + private static void skipSpaces(final ByteBuf byteBuf) throws IOException { while (byteBuf.isReadable()) { int ch = byteBuf.getByte(byteBuf.readerIndex()) & 0xFF; if (!(ch == ' ' || ch == '\r' || ch == '\n' || ch == '\t')) {