Update buffer readerIndex after XML parsing error 18/108818/2
authorSangwook Ha <sangwook.ha@verizon.com>
Thu, 2 Nov 2023 08:40:52 +0000 (01:40 -0700)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Fri, 3 Nov 2023 08:18:34 +0000 (09:18 +0100)
commit2504bde5d69fcb64fd2f7469a6c15707cc4984d2
tree440e6943399e9dc75ee190df7dbc9e09032ea874
parent1be63ad7109c383f04b3bffffab83e42be1c5b50
Update buffer readerIndex after XML parsing error

The readerIndex of the input buffer may have not reached the end
of the message when XML parsing fails. And in this case unnecessary
decoding may get repeatedly triggered for the unread partial message.

Make sure that readerIndex advances to writerIndex so that the next
decoding can start for a new message and add a test case to show this
parsing error scenario.

It means that we can skip all readable bytes counted by:
(ByteBuff.writerIndex - ByteBuff.readerIndex).

JIRA: NETCONF-1194
Change-Id: I01b668eb0c995ff01435e983cdbba1490645909e
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/NetconfXMLToMessageDecoder.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/NetconfXMLToMessageDecoderTest.java