Revert "BUG-2679 Workaround for wrong nagasena encode/decode with reused transmogrifier" 73/22973/3
authorMaros Marsalek <mmarsale@cisco.com>
Fri, 19 Jun 2015 07:58:13 +0000 (09:58 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 26 Jun 2015 07:50:53 +0000 (07:50 +0000)
This reverts commit 8bedb6be52f21b52d6df08d1501cf46f8ddbdbdc.

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

index 5d6d1aa083ad51ed2444fb8903e695191b56be4c..aceb6ac520f5568120c8538fb320f72f2c8418e4 100644 (file)
@@ -30,29 +30,23 @@ public final class NetconfMessageToEXIEncoder extends MessageToByteEncoder<Netco
     private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageToEXIEncoder.class);
     /**
      * This class is not marked as shared, so it can be attached to only a single channel,
-     * which means that {@link #encode(io.netty.channel.ChannelHandlerContext, org.opendaylight.controller.netconf.api.NetconfMessage, io.netty.buffer.ByteBuf)}
+     * which means that {@link #encode(ChannelHandlerContext, NetconfMessage, ByteBuf)}
      * cannot be invoked concurrently. Hence we can reuse the transmogrifier.
      */
-    private final NetconfEXICodec codec;
+    private final Transmogrifier transmogrifier;
 
-    private NetconfMessageToEXIEncoder(final NetconfEXICodec codec) {
-        this.codec = Preconditions.checkNotNull(codec);
+    private NetconfMessageToEXIEncoder(final Transmogrifier transmogrifier) {
+        this.transmogrifier = Preconditions.checkNotNull(transmogrifier);
     }
 
     public static NetconfMessageToEXIEncoder create(final NetconfEXICodec codec) throws EXIOptionsException, TransmogrifierException {
-        return new NetconfMessageToEXIEncoder(codec);
+        return new NetconfMessageToEXIEncoder(codec.getTransmogrifier());
     }
 
     @Override
     protected void encode(final ChannelHandlerContext ctx, final NetconfMessage msg, final ByteBuf out) throws EXIOptionsException, IOException, TransformerException, TransmogrifierException {
         LOG.trace("Sent to encode : {}", msg);
 
-        // TODO Workaround for bug 2679, recreate transmogrifier every time
-        // If the transmogrifier is reused, encoded xml can become non valid according to EXI decoder
-        // Seems like a bug in the nagasena library (try newer version of the library or fix the bug inside of it)
-        // Related bugs 2459: reuse nagasena resources, 2458: upgrade nagasena to newest version
-        final Transmogrifier transmogrifier = codec.getTransmogrifier();
-
         try (final OutputStream os = new ByteBufOutputStream(out)) {
             transmogrifier.setOutputStream(os);
             final ContentHandler handler = transmogrifier.getSAXTransmogrifier();