Add custom EXI buffer management
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / handler / NetconfEXIToMessageDecoder.java
index 99d791642a5f9bf1ff5a1d560d2a79b7afb126a1..0f85d18c16964be7b72b3d94fcb504f937e1a99d 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.netconf.nettyutil.handler;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufInputStream;
 import io.netty.buffer.ByteBufUtil;
@@ -24,9 +25,8 @@ import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.sax.SAXTransformerFactory;
 import javax.xml.transform.sax.TransformerHandler;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.shaded.exificient.core.exceptions.EXIException;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
-import org.openexi.proc.common.EXIOptionsException;
-import org.openexi.sax.EXIReader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -53,21 +53,21 @@ public final class NetconfEXIToMessageDecoder extends ByteToMessageDecoder {
      * which means that {@link #decode(ChannelHandlerContext, ByteBuf, List)}
      * cannot be invoked concurrently. Hence we can reuse the reader.
      */
-    private final EXIReader reader;
+    private final ThreadLocalSAXDecoder reader;
     private final DocumentBuilder documentBuilder;
 
-    private NetconfEXIToMessageDecoder(final EXIReader reader) {
-        this.reader = Preconditions.checkNotNull(reader);
+    private NetconfEXIToMessageDecoder(final ThreadLocalSAXDecoder reader) {
+        this.reader = requireNonNull(reader);
         this.documentBuilder = UntrustedXML.newDocumentBuilder();
     }
 
-    public static NetconfEXIToMessageDecoder create(final NetconfEXICodec codec) throws EXIOptionsException {
+    public static NetconfEXIToMessageDecoder create(final NetconfEXICodec codec) throws EXIException {
         return new NetconfEXIToMessageDecoder(codec.getReader());
     }
 
     @Override
     protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out)
-            throws EXIOptionsException, IOException, SAXException, TransformerConfigurationException  {
+            throws IOException, SAXException, TransformerConfigurationException {
         /*
          * Note that we could loop here and process all the messages, but we can't do that.
          * The reason is <stop-exi> operation, which has the contract of immediately stopping