BUG-3301 Extract additional header properly on each OS 93/20893/2
authorMaros Marsalek <mmarsale@cisco.com>
Thu, 21 May 2015 13:21:10 +0000 (15:21 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 22 May 2015 11:34:09 +0000 (11:34 +0000)
On Windows, the additional header in hello netconf message was no fully
extracted and it left \n byte in front on netconf xml hello message. This
is not allowed as long as the <?xml ... > declaration is present.

Change-Id: I611a5c689e86fb45065e6a9cd3b14cd5718af54f
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfXMLToHelloMessageDecoder.java

index 3ba49fc9f5f1520bde630838ef51a0259600a794..e6c5e5482da3328263599a6942df22e159f14dcb 100644 (file)
@@ -84,9 +84,9 @@ public final class NetconfXMLToHelloMessageDecoder extends ByteToMessageDecoder
                 // Auth information containing username, ip address... extracted for monitoring
                 int endOfAuthHeader = getAdditionalHeaderEndIndex(bytes);
                 if (endOfAuthHeader > -1) {
-                    byte[] additionalHeaderBytes = Arrays.copyOfRange(bytes, 0, endOfAuthHeader + 2);
+                    byte[] additionalHeaderBytes = Arrays.copyOfRange(bytes, 0, endOfAuthHeader);
                     additionalHeader = additionalHeaderToString(additionalHeaderBytes);
-                    bytes = Arrays.copyOfRange(bytes, endOfAuthHeader + 2, bytes.length);
+                    bytes = Arrays.copyOfRange(bytes, endOfAuthHeader, bytes.length);
                 }
             }
 
@@ -127,7 +127,7 @@ public final class NetconfXMLToHelloMessageDecoder extends ByteToMessageDecoder
             int idx = findByteSequence(bytes, possibleEnd);
 
             if (idx != -1) {
-                return idx;
+                return idx + possibleEnd.length;
             }
         }