BUG-3301 Extract additional header properly on each OS 40/20940/3
authorMaros Marsalek <mmarsale@cisco.com>
Thu, 21 May 2015 13:21:10 +0000 (15:21 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 26 May 2015 10:23:01 +0000 (10:23 +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 3ba49fc..e6c5e54 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;
             }
         }
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.