X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-netty-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnettyutil%2Fhandler%2FNetconfXMLToMessageDecoder.java;h=1dc8e0233b4b44241eb4e05eb218bb0eb5ae90d1;hp=bfc8d77e17bc7e4ae799d9b0859bdf3085f5e6af;hb=d762fe6c823ad1ba21db1cad627a1cbd6d7c6d8e;hpb=2f097c374a16b818f50f945cafc2461b9c5b8321 diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfXMLToMessageDecoder.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfXMLToMessageDecoder.java index bfc8d77e17..1dc8e0233b 100644 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfXMLToMessageDecoder.java +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfXMLToMessageDecoder.java @@ -12,20 +12,24 @@ import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufUtil; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; +import java.io.IOException; import java.util.List; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.xml.sax.SAXException; public final class NetconfXMLToMessageDecoder extends ByteToMessageDecoder { private static final Logger LOG = LoggerFactory.getLogger(NetconfXMLToMessageDecoder.class); @Override - public void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { + public void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List out) throws IOException, SAXException { + if (in.isReadable()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in)); + } - if (in.readableBytes() != 0) { - LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in)); out.add(new NetconfMessage(XmlUtil.readXmlToDocument(new ByteBufInputStream(in)))); } else { LOG.debug("No more content in incoming buffer.");