Suppress modernization 33/83833/28
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 20 Aug 2019 19:29:51 +0000 (21:29 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 24 Sep 2019 11:14:10 +0000 (13:14 +0200)
Modernize as much as possible, but as we have legacy APIs in play,
we have to add also some suppressions.

Change-Id: I844821f129ad0bb0e186b6a4848a6d2937513f7b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
15 files changed:
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintBundleTracker.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/ComponentProcessor.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingMountPointAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapterTest.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardDataTreeListenerInfoMXBeanImpl.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransactionTest.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMMountPointAdapter.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/mount/SimpleDOMMountPoint.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/rpc/RpcRoutingStrategy.java

index ebc6975..bb13e13 100644 (file)
@@ -21,6 +21,7 @@ import org.apache.aries.blueprint.services.BlueprintExtenderService;
 import org.apache.aries.quiesce.participant.QuiesceParticipant;
 import org.apache.aries.util.AriesFrameworkUtil;
 import org.eclipse.jdt.annotation.Nullable;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.opendaylight.controller.blueprint.ext.OpendaylightNamespaceHandler;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.osgi.framework.Bundle;
@@ -88,7 +89,7 @@ public class BlueprintBundleTracker implements BundleActivator, BundleTrackerCus
 
         bundleTracker = new BundleTracker<>(context, Bundle.ACTIVE, this);
 
-        blueprintExtenderServiceTracker = new ServiceTracker<>(context, BlueprintExtenderService.class.getName(),
+        blueprintExtenderServiceTracker = new ServiceTracker<>(context, BlueprintExtenderService.class,
                 new ServiceTrackerCustomizer<BlueprintExtenderService, BlueprintExtenderService>() {
                     @Override
                     public BlueprintExtenderService addingService(
@@ -108,7 +109,7 @@ public class BlueprintBundleTracker implements BundleActivator, BundleTrackerCus
                 });
         blueprintExtenderServiceTracker.open();
 
-        quiesceParticipantTracker = new ServiceTracker<>(context, QuiesceParticipant.class.getName(),
+        quiesceParticipantTracker = new ServiceTracker<>(context, QuiesceParticipant.class,
                 new ServiceTrackerCustomizer<QuiesceParticipant, QuiesceParticipant>() {
                     @Override
                     public QuiesceParticipant addingService(
@@ -150,21 +151,25 @@ public class BlueprintBundleTracker implements BundleActivator, BundleTrackerCus
 
         restartService.setBlueprintExtenderService(blueprintExtenderService);
 
-        blueprintContainerRestartReg = bundleContext.registerService(
-                BlueprintContainerRestartService.class.getName(), restartService, new Hashtable<>());
+        blueprintContainerRestartReg = bundleContext.registerService(BlueprintContainerRestartService.class,
+            restartService, null);
 
         return blueprintExtenderService;
     }
 
     private void registerNamespaceHandler(final BundleContext context) {
-        Dictionary<String, Object> props = new Hashtable<>();
+        Dictionary<String, Object> props = emptyDict();
         props.put("osgi.service.blueprint.namespace", OpendaylightNamespaceHandler.NAMESPACE_1_0_0);
-        namespaceReg = context.registerService(NamespaceHandler.class.getName(),
-                new OpendaylightNamespaceHandler(), props);
+        namespaceReg = context.registerService(NamespaceHandler.class, new OpendaylightNamespaceHandler(), props);
     }
 
     private void registerBlueprintEventHandler(final BundleContext context) {
-        eventHandlerReg = context.registerService(BlueprintListener.class.getName(), this, new Hashtable<>());
+        eventHandlerReg = context.registerService(BlueprintListener.class, this, null);
+    }
+
+    @SuppressModernizer
+    private static Dictionary<String, Object> emptyDict() {
+        return new Hashtable<>();
     }
 
     /**
index 0e52cb6..4a8c015 100644 (file)
@@ -16,7 +16,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Deque;
-import java.util.Hashtable;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
@@ -226,7 +225,7 @@ class BlueprintContainerRestartServiceImpl implements AutoCloseable, BlueprintCo
 
     private static ServiceRegistration<?> registerEventHandler(final BundleContext bundleContext,
             final BlueprintListener listener) {
-        return bundleContext.registerService(BlueprintListener.class.getName(), listener, new Hashtable<>());
+        return bundleContext.registerService(BlueprintListener.class, listener, null);
     }
 
     @Override
index 84847a1..2f0709f 100644 (file)
@@ -20,6 +20,7 @@ import org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder;
 import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
 import org.apache.aries.blueprint.mutable.MutableServiceReferenceMetadata;
 import org.apache.aries.util.AriesFrameworkUtil;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.opendaylight.controller.blueprint.BlueprintContainerRestartService;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
@@ -131,6 +132,7 @@ public class ComponentProcessor implements ComponentDefinitionRegistryProcessor
         }
     }
 
+    @SuppressModernizer
     private void registerManagedService(final String persistentId) {
         // Register a ManagedService so we get updates from the ConfigAdmin when the cfg file corresponding
         // to the persistentId changes.
@@ -158,8 +160,7 @@ public class ComponentProcessor implements ComponentDefinitionRegistryProcessor
         props.put(Constants.SERVICE_PID, persistentId);
         props.put(Constants.BUNDLE_SYMBOLICNAME, bundle.getSymbolicName());
         props.put(Constants.BUNDLE_VERSION, bundle.getHeaders().get(Constants.BUNDLE_VERSION));
-        managedServiceRegs.add(bundle.getBundleContext().registerService(ManagedService.class.getName(),
-                managedService, props));
+        managedServiceRegs.add(bundle.getBundleContext().registerService(ManagedService.class, managedService, props));
     }
 
     private String logName() {
index d953ef5..d66eb1c 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
+import static com.google.common.base.Preconditions.checkArgument;
+
 import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FluentFuture;
 import java.util.Map.Entry;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.mdsal.common.api.CommitInfo;
@@ -33,7 +35,7 @@ public abstract class AbstractWriteTransaction<T extends DOMDataWriteTransaction
 
     public final <U extends DataObject> void put(final LogicalDatastoreType store,
             final InstanceIdentifier<U> path, final U data, final boolean createParents) {
-        Preconditions.checkArgument(!path.isWildcarded(), "Cannot put data into wildcarded path %s", path);
+        checkArgument(!path.isWildcarded(), "Cannot put data into wildcarded path %s", path);
 
         final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec().toNormalizedNode(path, data);
         if (createParents) {
@@ -47,7 +49,7 @@ public abstract class AbstractWriteTransaction<T extends DOMDataWriteTransaction
 
     public final <U extends DataObject> void merge(final LogicalDatastoreType store,
             final InstanceIdentifier<U> path, final U data,final boolean createParents) {
-        Preconditions.checkArgument(!path.isWildcarded(), "Cannot merge data into wildcarded path %s", path);
+        checkArgument(!path.isWildcarded(), "Cannot merge data into wildcarded path %s", path);
 
         final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec().toNormalizedNode(path, data);
         if (createParents) {
@@ -94,7 +96,7 @@ public abstract class AbstractWriteTransaction<T extends DOMDataWriteTransaction
             final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalized) {
         if (Identifiable.class.isAssignableFrom(path.getTargetType())) {
             YangInstanceIdentifier parentMapPath = normalized.getKey().getParent();
-            Preconditions.checkArgument(parentMapPath != null, "Map path %s does not have a parent", path);
+            checkArgument(parentMapPath != null, "Map path %s does not have a parent", path);
 
             NormalizedNode<?, ?> emptyParent = getCodec().getDefaultNodeFor(parentMapPath);
             getDelegate().merge(store, parentMapPath, emptyParent);
@@ -107,6 +109,7 @@ public abstract class AbstractWriteTransaction<T extends DOMDataWriteTransaction
      * @deprecated Use {@link YangInstanceIdentifier#getParent()} instead.
      */
     @Deprecated
+    @SuppressModernizer
     protected static Optional<YangInstanceIdentifier> getParent(final YangInstanceIdentifier child) {
         return Optional.fromNullable(child.getParent());
     }
@@ -120,7 +123,7 @@ public abstract class AbstractWriteTransaction<T extends DOMDataWriteTransaction
 
     protected final void doDelete(final LogicalDatastoreType store,
             final InstanceIdentifier<?> path) {
-        Preconditions.checkArgument(!path.isWildcarded(), "Cannot delete wildcarded path %s", path);
+        checkArgument(!path.isWildcarded(), "Cannot delete wildcarded path %s", path);
 
         final YangInstanceIdentifier normalized = getCodec().toYangInstanceIdentifierBlocking(path);
         getDelegate().delete(store, normalized);
index 39c64e7..f6df2c7 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.base.Optional;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.opendaylight.controller.md.sal.binding.api.MountPoint;
 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
@@ -44,6 +45,7 @@ public class BindingDOMMountPointServiceAdapter implements MountPointService {
     }
 
     @Override
+    @SuppressModernizer
     public Optional<MountPoint> getMountPoint(final InstanceIdentifier<?> mountPoint) {
 
         YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(mountPoint);
index 360c94d..1f45bed 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.md.sal.binding.impl;
 import com.google.common.base.Optional;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.LoadingCache;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.opendaylight.controller.md.sal.binding.api.BindingService;
 import org.opendaylight.controller.md.sal.binding.api.MountPoint;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
@@ -27,7 +28,7 @@ public class BindingMountPointAdapter implements MountPoint {
         services = CacheBuilder.newBuilder().build(new BindingDOMAdapterLoader(codec) {
 
             @Override
-            protected DOMService getDelegate(Class<? extends DOMService> reqDeleg) {
+            protected DOMService getDelegate(final Class<? extends DOMService> reqDeleg) {
                 return domMountPoint.getService(reqDeleg).orNull();
             }
         });
@@ -39,7 +40,8 @@ public class BindingMountPointAdapter implements MountPoint {
     }
 
     @Override
-    public <T extends BindingService> Optional<T> getService(Class<T> service) {
+    @SuppressModernizer
+    public <T extends BindingService> Optional<T> getService(final Class<T> service) {
         Optional<BindingService> potential = services.getUnchecked(service);
         if (potential.isPresent()) {
             return Optional.of(service.cast(potential.get()));
index 405d190..6eab349 100644 (file)
@@ -11,11 +11,13 @@ import com.google.common.base.Optional;
 import com.google.common.cache.CacheLoader;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 
 @Deprecated
 public abstract class AdapterLoader<T, D> extends CacheLoader<Class<? extends T>, Optional<T>> {
 
     @Override
+    @SuppressModernizer
     public Optional<T> load(final Class<? extends T> key) {
 
         final AdapterBuilder<? extends T, D> builder = createBuilder(key);
index 0697833..7c022b0 100644 (file)
@@ -8,13 +8,16 @@
 package org.opendaylight.controller.md.sal.binding.impl;
 
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
 
 import com.google.common.base.Optional;
 import com.google.common.cache.LoadingCache;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
-import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
@@ -38,14 +41,15 @@ public class BindingDOMMountPointServiceAdapterTest {
     private ClassLoadingStrategy classLoadingStrategy;
 
     @Before
+    @SuppressModernizer
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        codec = Mockito.spy(new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry));
-        Mockito.doAnswer(invocationOnMock -> Optional.of(Mockito.mock(DOMMountPoint.class)))
+        codec = spy(new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry));
+        doReturn(Optional.of(mock(DOMMountPoint.class)))
                 .when(mountService).getMountPoint(any(YangInstanceIdentifier.class));
-        Mockito.doReturn(YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(QName.create("(a)b"))))
+        doReturn(YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(QName.create("(a)b"))))
                 .when(codec).toYangInstanceIdentifierBlocking(any(InstanceIdentifier.class));
-        Mockito.doReturn(InstanceIdentifier.create(DataObject.class))
+        doReturn(InstanceIdentifier.create(DataObject.class))
                 .when(codecRegistry).fromYangInstanceIdentifier(any(YangInstanceIdentifier.class));
     }
 
index b17c5d3..7ad1b54 100644 (file)
@@ -20,6 +20,7 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -138,6 +139,7 @@ public class CrossBrokerMountPointTest {
                     return  new DOMDataReadWriteTransaction() {
 
                         @Override
+                        @SuppressModernizer
                         public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
                                 final LogicalDatastoreType store, final YangInstanceIdentifier path) {
                             if (store == LogicalDatastoreType.OPERATIONAL && path.getLastPathArgument()
index 2614caf..fa44c8d 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.controller.md.sal.common.impl.util.compat;
 
 import com.google.common.base.Optional;
-import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.Collections;
 import java.util.HashSet;
@@ -19,6 +19,8 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import org.eclipse.jdt.annotation.Nullable;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
@@ -49,7 +51,7 @@ import org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema;
 public abstract class DataNormalizationOperation<T extends PathArgument> implements Identifiable<T> {
 
     private final T identifier;
-    private final Optional<DataSchemaNode> dataSchemaNode;
+    private final DataSchemaNode dataSchemaNode;
 
     @Override
     public T getIdentifier() {
@@ -58,11 +60,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
 
     protected DataNormalizationOperation(final T identifier, final SchemaNode schema) {
         this.identifier = identifier;
-        if (schema instanceof DataSchemaNode) {
-            this.dataSchemaNode = Optional.of((DataSchemaNode) schema);
-        } else {
-            this.dataSchemaNode = Optional.absent();
-        }
+        dataSchemaNode = schema instanceof DataSchemaNode ? (DataSchemaNode)schema : null;
     }
 
     public boolean isMixin() {
@@ -84,9 +82,9 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
 
     public abstract boolean isLeaf();
 
+    @SuppressModernizer
     public Optional<DataSchemaNode> getDataSchemaNode() {
-        // FIXME
-        return dataSchemaNode;
+        return Optional.fromNullable(dataSchemaNode);
     }
 
     private abstract static class SimpleTypeNormalization<T extends PathArgument>
@@ -206,14 +204,13 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         private static DataNormalizationOperation<?> fromSchemaAndQNameChecked(final DataNodeContainer schema,
                 final QName child) throws DataNormalizationException {
 
-            final Optional<DataSchemaNode> potential = findChildSchemaNode(schema, child);
-            if (!potential.isPresent()) {
+            final DataSchemaNode result = findChildSchemaNode(schema, child);
+            if (result == null) {
                 throw new DataNormalizationException(String.format(
                         "Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child,
                         schema,schema.getChildNodes()));
             }
 
-            final DataSchemaNode result = potential.get();
             // We try to look up if this node was added by augmentation
             if (schema instanceof DataSchemaNode && result.isAugmenting()) {
                 return fromAugmentation(schema, (AugmentationTarget) schema, result);
@@ -352,12 +349,11 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         @Override
         protected DataNormalizationOperation<?> fromLocalSchemaAndQName(final DataNodeContainer schema,
                 final QName child) {
-            final Optional<DataSchemaNode> potential = findChildSchemaNode(schema, child);
-            if (!potential.isPresent()) {
+            final DataSchemaNode result = findChildSchemaNode(schema, child);
+            if (result == null) {
                 return null;
             }
 
-            final DataSchemaNode result = potential.get();
             // We try to look up if this node was added by augmentation
             if (schema instanceof DataSchemaNode && result.isAugmenting()) {
                 return fromAugmentation(schema, (AugmentationTarget) schema, result);
@@ -513,28 +509,20 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         }
     }
 
-    private static Optional<DataSchemaNode> findChildSchemaNode(final DataNodeContainer parent,
-            final QName child) {
-        DataSchemaNode potential = parent.getDataChildByName(child);
-        if (potential == null) {
-            final Iterable<ChoiceSchemaNode> choices = FluentIterable.from(parent.getChildNodes())
-                    .filter(ChoiceSchemaNode.class);
-            potential = findChoice(choices, child);
-        }
-        return Optional.fromNullable(potential);
+    private static @Nullable DataSchemaNode findChildSchemaNode(final DataNodeContainer parent, final QName child) {
+        final DataSchemaNode potential = parent.getDataChildByName(child);
+        return potential != null ? potential : findChoice(parent, child);
     }
 
-    private static ChoiceSchemaNode findChoice(final Iterable<ChoiceSchemaNode> choices, final QName child) {
-        ChoiceSchemaNode foundChoice = null;
-        choiceLoop: for (final ChoiceSchemaNode choice : choices) {
+    private static @Nullable ChoiceSchemaNode findChoice(final DataNodeContainer parent, final QName child) {
+        for (final ChoiceSchemaNode choice : Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class)) {
             for (final CaseSchemaNode caze : choice.getCases().values()) {
-                if (findChildSchemaNode(caze, child).isPresent()) {
-                    foundChoice = choice;
-                    break choiceLoop;
+                if (findChildSchemaNode(caze, child) != null) {
+                    return choice;
                 }
             }
         }
-        return foundChoice;
+        return null;
     }
 
     public static AugmentationIdentifier augmentationIdentifierFrom(final AugmentationSchemaNode augmentation) {
index 6c6726c..6384735 100644 (file)
@@ -15,11 +15,14 @@ import akka.dispatch.Futures;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
 import com.google.common.base.Throwables;
+import com.google.common.collect.Streams;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
 import org.opendaylight.controller.cluster.datastore.messages.DataTreeListenerInfo;
 import org.opendaylight.controller.cluster.datastore.messages.GetInfo;
 import org.opendaylight.controller.cluster.datastore.messages.OnDemandShardState;
@@ -68,13 +71,14 @@ public class ShardDataTreeListenerInfoMXBeanImpl extends AbstractMXBean implemen
             futureList.add(Patterns.ask(actor, GetInfo.INSTANCE, timeout));
         }
 
+        final Iterable<Object> listenerInfos;
         try {
-            final List<DataTreeListenerInfo> listenerInfoList = new ArrayList<>();
-            Await.result(Futures.sequence(futureList, ExecutionContext.Implicits$.MODULE$.global()),
-                    timeout.duration()).forEach(obj -> listenerInfoList.add((DataTreeListenerInfo) obj));
-            return listenerInfoList;
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+            listenerInfos = Await.result(Futures.sequence(futureList, ExecutionContext.Implicits$.MODULE$.global()),
+                timeout.duration());
+        } catch (TimeoutException | InterruptedException e) {
+            throw new IllegalStateException("Failed to acquire listeners", e);
         }
+
+        return Streams.stream(listenerInfos).map(DataTreeListenerInfo.class::cast).collect(Collectors.toList());
     }
 }
index e1a71d6..8286909 100644 (file)
@@ -17,6 +17,7 @@ import static org.mockito.Mockito.verify;
 
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.Futures;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Matchers;
@@ -67,6 +68,7 @@ public class ShardedDOMDataBrokerDelegatingReadWriteTransactionTest {
     }
 
     @Test
+    @SuppressModernizer
     public void testReadWriteOperations() throws Exception {
         doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(readTx).read(any(), any());
         rwTx.put(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH, testNodeWithOuter(1, 2, 3));
@@ -88,7 +90,7 @@ public class ShardedDOMDataBrokerDelegatingReadWriteTransactionTest {
         assertEquals(Optional.absent(), rwTx.read(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH).checkedGet());
     }
 
-    private static DataContainerChild<?, ?> outerNode(int... ids) {
+    private static DataContainerChild<?, ?> outerNode(final int... ids) {
         CollectionNodeBuilder<MapEntryNode, MapNode> outer = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME);
         for (int id : ids) {
             outer.addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, id));
@@ -97,11 +99,11 @@ public class ShardedDOMDataBrokerDelegatingReadWriteTransactionTest {
         return outer.build();
     }
 
-    private static NormalizedNode<?, ?> testNodeWithOuter(int... ids) {
+    private static NormalizedNode<?, ?> testNodeWithOuter(final int... ids) {
         return testNodeWithOuter(outerNode(ids));
     }
 
-    private static NormalizedNode<?, ?> testNodeWithOuter(DataContainerChild<?, ?> outer) {
+    private static NormalizedNode<?, ?> testNodeWithOuter(final DataContainerChild<?, ?> outer) {
         return ImmutableContainerNodeBuilder.create()
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(outer)
                 .build();
index b780914..c6aaed8 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.collect.ForwardingObject;
 import com.google.common.collect.ImmutableMap;
 import java.util.Map;
 import org.eclipse.jdt.annotation.Nullable;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.opendaylight.controller.md.sal.dom.api.DOMActionService;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
@@ -87,6 +88,7 @@ public class DOMMountPointAdapter extends ForwardingObject implements DOMMountPo
     }
 
     @Override
+    @SuppressModernizer
     public <T extends DOMService> Optional<T> getService(final Class<T> cls) {
         final java.util.Optional<T> found = delegate.getService(cls);
         if (found.isPresent()) {
index 99f1eca..b9b5838 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.collect.ClassToInstanceMap;
 import com.google.common.collect.ImmutableClassToInstanceMap;
 import java.util.Map.Entry;
 import java.util.Set;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.controller.md.sal.dom.api.DOMService;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -47,6 +48,7 @@ public final class SimpleDOMMountPoint implements DOMMountPoint {
     }
 
     @Override
+    @SuppressModernizer
     public <T extends DOMService> Optional<T> getService(final Class<T> cls) {
         return Optional.fromNullable(services.getInstance(cls));
     }
index 96bf5a8..f55cb87 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.md.sal.dom.broker.spi.rpc;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.base.Optional;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -71,6 +72,7 @@ public abstract class RpcRoutingStrategy implements Identifiable<QName> {
         return new GlobalRpcStrategy(rpc.getQName());
     }
 
+    @SuppressModernizer
     public static Optional<QName> getRoutingContext(final DataSchemaNode schemaNode) {
         for (UnknownSchemaNode extension : schemaNode.getUnknownSchemaNodes()) {
             if (CONTEXT_REFERENCE.equals(extension.getNodeType())) {
@@ -107,7 +109,6 @@ public abstract class RpcRoutingStrategy implements Identifiable<QName> {
     }
 
     private static final class GlobalRpcStrategy extends RpcRoutingStrategy {
-
         GlobalRpcStrategy(final QName identifier) {
             super(identifier);
         }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.