Merge "Close read-only transactions"
authorTomas Cere <tomas.cere@pantheon.tech>
Wed, 15 May 2019 07:15:30 +0000 (07:15 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 15 May 2019 07:15:30 +0000 (07:15 +0000)
1  2 
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMount.java

index f49ddd9b74d57c26f98dfa4cd35e6441f5935982,223354d615b4b6e2367d246545f3c8527a2c4946..c67995b4126d753fb4187fca6b188beaa8ba50ae
@@@ -8,7 -8,6 +8,6 @@@
  package org.opendaylight.netconf.messagebus.eventsources.netconf;
  
  import com.google.common.base.Preconditions;
- import com.google.common.util.concurrent.FluentFuture;
  import com.google.common.util.concurrent.ListenableFuture;
  import java.time.Instant;
  import java.time.ZoneId;
@@@ -18,9 -17,12 +17,9 @@@ import java.util.Collections
  import java.util.List;
  import java.util.Optional;
  import java.util.concurrent.ExecutionException;
 -import javassist.ClassPool;
 -import org.opendaylight.mdsal.binding.dom.codec.gen.impl.StreamWriterGenerator;
  import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
  import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
  import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
 -import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
  import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
  import org.opendaylight.mdsal.dom.api.DOMDataBroker;
  import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
@@@ -62,7 -64,9 +61,7 @@@ class NetconfEventSourceMount 
                  .xml.ns.netmod.notification.rev080714.$YangModuleInfoImpl.getInstance()));
          SchemaContext notificationsSchemaCtx = moduleInfoBackedContext.tryToCreateSchemaContext().get();
  
 -        final JavassistUtils javassist = JavassistUtils.forClassPool(ClassPool.getDefault());
 -        CODEC_REGISTRY = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(javassist));
 -        CODEC_REGISTRY.onBindingRuntimeContextUpdated(BindingRuntimeContext.create(moduleInfoBackedContext,
 +        CODEC_REGISTRY = new BindingNormalizedNodeCodecRegistry(BindingRuntimeContext.create(moduleInfoBackedContext,
                  notificationsSchemaCtx));
      }
  
       * @throws InterruptedException if data read fails
       */
      List<Stream> getAvailableStreams() throws InterruptedException, ExecutionException {
-         DOMDataTreeReadTransaction tx = dataBroker.newReadOnlyTransaction();
-         FluentFuture<Optional<NormalizedNode<?, ?>>> checkFeature = tx.read(LogicalDatastoreType.OPERATIONAL,
-             STREAMS_PATH);
-         Optional<NormalizedNode<?, ?>> streams = checkFeature.get();
+         final Optional<NormalizedNode<?, ?>> streams;
+         try (DOMDataTreeReadTransaction tx = dataBroker.newReadOnlyTransaction()) {
+             streams = tx.read(LogicalDatastoreType.OPERATIONAL, STREAMS_PATH).get();
+         }
          if (streams.isPresent()) {
              Streams streams1 = (Streams) CODEC_REGISTRY.fromNormalizedNode(STREAMS_PATH, streams.get()).getValue();
              return streams1.getStream();