From: Robert Varga Date: Sat, 8 Feb 2014 02:45:52 +0000 (+0100) Subject: Rewrite POSSIBLE_ENDS and POSSIBLE_STARTS X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~487 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=refs%2Fchanges%2F99%2F5199%2F3 Rewrite POSSIBLE_ENDS and POSSIBLE_STARTS These two are really simple byte arrays, initialized them as such withouth going through strings/UTF8. Change-Id: Id80151d9ff57df4b7a5595f76f30a379d89af3dd Signed-off-by: Robert Varga --- diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfXMLToMessageDecoder.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfXMLToMessageDecoder.java index 62a06e6e20..2eefb91724 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfXMLToMessageDecoder.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfXMLToMessageDecoder.java @@ -33,11 +33,13 @@ import com.google.common.collect.ImmutableList; public final class NetconfXMLToMessageDecoder extends ByteToMessageDecoder { private static final Logger LOG = LoggerFactory.getLogger(NetconfXMLToMessageDecoder.class); - // FIXME: this is funky way of creating arrays private static final List POSSIBLE_ENDS = ImmutableList.of( - "]\n".getBytes(Charsets.UTF_8), "]\r\n".getBytes(Charsets.UTF_8)); + new byte[] { ']', '\n' }, + new byte[] { ']', '\r', '\n' }); private static final List POSSIBLE_STARTS = ImmutableList.of( - "[".getBytes(Charsets.UTF_8), "\r\n[".getBytes(Charsets.UTF_8), "\n[".getBytes(Charsets.UTF_8)); + new byte[] { '[' }, + new byte[] { '\r', '\n', '[' }, + new byte[] { '\n', '[' }); @Override @VisibleForTesting @@ -57,6 +59,10 @@ public final class NetconfXMLToMessageDecoder extends ByteToMessageDecoder { String additionalHeader = null; + // FIXME: this has to be moved into the negotiator and explained as to what the heck + // is going on. This is definitely not specified in NETCONF and has no place here. It + // requires reading all data and incurs inefficiency by being unable to pipe the ByteBuf + // directly into the XML decoder. if (startsWithAdditionalHeader(bytes)) { // Auth information containing username, ip address... extracted for monitoring int endOfAuthHeader = getAdditionalHeaderEndIndex(bytes);