X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Fconnect%2Fnetconf%2Fsal%2FNetconfDeviceSalProvider.java;h=ead5348311672a507919a2fd0e645bc113fc75a3;hb=6975248489c083942ec93131dac8e6eb95d66806;hp=7b578a35dcd980aa8c4cdba5991ad651dac9f306;hpb=1d91e1bbe29d0da6ea427a5d0837064c8a3d5134;p=netconf.git diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceSalProvider.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceSalProvider.java index 7b578a35dc..ead5348311 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceSalProvider.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceSalProvider.java @@ -7,7 +7,11 @@ */ package org.opendaylight.netconf.sal.connect.netconf.sal; -import com.google.common.base.Preconditions; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.Transaction; import org.opendaylight.mdsal.binding.api.TransactionChain; @@ -26,7 +30,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class NetconfDeviceSalProvider implements AutoCloseable { - private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceSalProvider.class); private final RemoteDeviceId id; @@ -63,30 +66,30 @@ public class NetconfDeviceSalProvider implements AutoCloseable { mountInstance = new MountInstance(mountService, id); this.dataBroker = dataBroker; if (dataBroker != null) { - txChain = Preconditions.checkNotNull(dataBroker).createTransactionChain(transactionChainListener); + txChain = requireNonNull(dataBroker).createTransactionChain(transactionChainListener); topologyDatastoreAdapter = new NetconfDeviceTopologyAdapter(id, txChain); } } public MountInstance getMountInstance() { - Preconditions.checkState(mountInstance != null, - "%s: Mount instance was not initialized by sal. Cannot get mount instance", id); + checkState(mountInstance != null, "%s: Mount instance was not initialized by sal. Cannot get mount instance", + id); return mountInstance; } public NetconfDeviceTopologyAdapter getTopologyDatastoreAdapter() { - Preconditions.checkState(topologyDatastoreAdapter != null, - "%s: Sal provider %s was not initialized by sal. Cannot get topology datastore adapter", id); - return topologyDatastoreAdapter; + final NetconfDeviceTopologyAdapter local = topologyDatastoreAdapter; + checkState(local != null, + "%s: Sal provider %s was not initialized by sal. Cannot get topology datastore adapter", id, this); + return local; } + @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "https://github.com/spotbugs/spotbugs/issues/811") private void resetTransactionChainForAdapaters() { - txChain = Preconditions.checkNotNull(dataBroker).createTransactionChain(transactionChainListener); - + txChain = requireNonNull(dataBroker).createTransactionChain(transactionChainListener); topologyDatastoreAdapter.setTxChain(txChain); - LOG.trace("{}: Resetting TransactionChain {}", id, txChain); - } @Override @@ -110,8 +113,8 @@ public class NetconfDeviceSalProvider implements AutoCloseable { private ObjectRegistration topologyRegistration; MountInstance(final DOMMountPointService mountService, final RemoteDeviceId id) { - this.mountService = Preconditions.checkNotNull(mountService); - this.id = Preconditions.checkNotNull(id); + this.mountService = requireNonNull(mountService); + this.id = requireNonNull(id); } public void onTopologyDeviceConnected(final SchemaContext initialCtx, @@ -123,8 +126,8 @@ public class NetconfDeviceSalProvider implements AutoCloseable { public synchronized void onTopologyDeviceConnected(final SchemaContext initialCtx, final DOMDataBroker broker, final DOMRpcService rpc, final NetconfDeviceNotificationService newNotificationService, final DOMActionService deviceAction) { - Preconditions.checkNotNull(mountService, "Closed"); - Preconditions.checkState(topologyRegistration == null, "Already initialized"); + requireNonNull(mountService, "Closed"); + checkState(topologyRegistration == null, "Already initialized"); final DOMMountPointService.DOMMountPointBuilder mountBuilder = mountService.createMountPoint(id.getTopologyPath()); @@ -166,9 +169,8 @@ public class NetconfDeviceSalProvider implements AutoCloseable { } public synchronized void publish(final DOMNotification domNotification) { - Preconditions.checkNotNull(notificationService, "Device not set up yet, cannot handle notification {}", - domNotification); - notificationService.publishNotification(domNotification); + checkNotNull(notificationService, "Device not set up yet, cannot handle notification %s", domNotification) + .publishNotification(domNotification); } }