Fix checkstyle 34/107634/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 31 Aug 2023 14:04:05 +0000 (16:04 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 31 Aug 2023 14:14:08 +0000 (16:14 +0200)
Upgraded checkstyle is finding a few violations, fix them up.

Change-Id: Iaa581a6616d2a46baaf49d960cdf7835192eee76
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/extensions/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/SimpleEvpnNlriRegistryTest.java
bgp/extensions/evpn/src/test/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEsiTypeRegistryTest.java
bgp/extensions/mvpn/src/test/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/tunnel/identifier/PAddressPMulticastGroupUtilTest.java
bgp/extensions/mvpn/src/test/java/org/opendaylight/protocol/bgp/mvpn/spi/pojo/nlri/SimpleMvpnNlriRegistryTest.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/protocol/BGPProtocolSessionPromise.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractRIBTestSetup.java
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/DefaultRIBExtensionProviderContextTest.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPProtocolSessionPromise.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImplTest.java

index 80a4a8860b3a4fc0f6002832eaee4d25d52efb88..c06e577e1ef319da116f38241d23faabd1a1f457 100644 (file)
@@ -28,15 +28,15 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 
 public final class SimpleEvpnNlriRegistryTest {
-    public static final NodeIdentifier EVPN_NID = new NodeIdentifier(EvpnChoice.QNAME);
-
-    private class NotRegistered implements EvpnChoice {
+    private static final class NotRegistered implements EvpnChoice {
         @Override
         public Class<NotRegistered> implementedInterface() {
             return NotRegistered.class;
         }
     }
 
+    public static final NodeIdentifier EVPN_NID = new NodeIdentifier(EvpnChoice.QNAME);
+
     @Test
     public void registryTest() {
         final ByteBuf buff = SimpleEvpnNlriRegistry.getInstance().serializeEvpn(ETHERNET_AD_ROUTE_CASE,
index 587efdd3cb290ff568fec5f2f5a9944619b4cad3..f95cc1e2e5c5be11db723745ad265d273592eb41 100644 (file)
@@ -25,15 +25,15 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 
 public class SimpleEsiTypeRegistryTest {
-    private static final int ESI_TYPE_LENGTH = 10;
-
-    private class NotRegistered implements Esi {
+    private static final class NotRegistered implements Esi {
         @Override
         public Class<NotRegistered> implementedInterface() {
             return NotRegistered.class;
         }
     }
 
+    private static final int ESI_TYPE_LENGTH = 10;
+
     @Test
     public void registryTest() {
         final ByteBuf buff = Unpooled.buffer(ESI_TYPE_LENGTH);
index 11bba6cfbef9c1e3a6cc9877edba441393e1fa24..a1f98f1bc8bfa4ce633ed73180b9c36b9a58898a 100644 (file)
@@ -65,7 +65,7 @@ public final class PAddressPMulticastGroupUtilTest {
         assertEquals(P_MULTICAST, actual.getPMulticastGroup());
     }
 
-    private static class MyPAddressPMulticastGroup implements PAddressPMulticastGroup {
+    private static final class MyPAddressPMulticastGroup implements PAddressPMulticastGroup {
         @Override
         public IpAddressNoZone getPAddress() {
             return IP_ADDRESS;
index b64172d62d0f5e2fa4ca4d6433555a0c246c493b..4d6e8db4716c32d3c148146e205f73c9c9d0ad42 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.bgp.mvpn.spi.pojo.nlri;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -16,9 +17,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.mvpn.MvpnChoice;
 
 public final class SimpleMvpnNlriRegistryTest {
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void registryParseTest() {
-        SimpleMvpnNlriRegistry.getInstance().parseMvpn(NlriType.InterAsIPmsiAD, null);
+        assertThrows(IllegalArgumentException.class,
+            () -> SimpleMvpnNlriRegistry.getInstance().parseMvpn(NlriType.InterAsIPmsiAD, null));
     }
 
     @Test
@@ -28,7 +30,7 @@ public final class SimpleMvpnNlriRegistryTest {
         assertEquals(0, body.readableBytes());
     }
 
-    private class NotRegistered implements MvpnChoice {
+    private static final class NotRegistered implements MvpnChoice {
         @Override
         public Class<NotRegistered> implementedInterface() {
             return NotRegistered.class;
index 12efb5e2b0d3f2e8dfbd832da87e5910e37ca4f3..e59e87e696a5d66b818ee19bd6d80bdf241d487d 100644 (file)
@@ -50,49 +50,49 @@ public final class BGPProtocolSessionPromise<S extends BGPSession> extends Defau
     public BGPProtocolSessionPromise(final @NonNull InetSocketAddress remoteAddress, final int retryTimer,
             final @NonNull Bootstrap bootstrap, final @NonNull BGPPeerRegistry peerRegistry) {
         super(GlobalEventExecutor.INSTANCE);
-        this.address = requireNonNull(remoteAddress);
+        address = requireNonNull(remoteAddress);
         this.retryTimer = retryTimer;
         this.bootstrap = requireNonNull(bootstrap);
-        this.listenerRegistration = requireNonNull(peerRegistry).registerPeerSessionListener(
-                new PeerRegistrySessionListenerImpl(StrictBGPPeerRegistry.getIpAddress(this.address)));
+        listenerRegistration = requireNonNull(peerRegistry).registerPeerSessionListener(
+                new PeerRegistrySessionListenerImpl(StrictBGPPeerRegistry.getIpAddress(address)));
     }
 
     @SuppressWarnings("checkstyle:illegalCatch")
     public synchronized void connect() {
-        if (this.peerSessionPresent) {
-            LOG.debug("Connection to {} already exists", this.address);
-            this.connectSkipped = true;
+        if (peerSessionPresent) {
+            LOG.debug("Connection to {} already exists", address);
+            connectSkipped = true;
             return;
         }
 
-        this.connectSkipped = false;
+        connectSkipped = false;
 
         final BGPProtocolSessionPromise<?> lock = this;
         try {
             LOG.debug("Promise {} attempting connect for {}ms", lock, CONNECT_TIMEOUT);
-            if (this.address.isUnresolved()) {
-                this.address = new InetSocketAddress(this.address.getHostName(), this.address.getPort());
+            if (address.isUnresolved()) {
+                address = new InetSocketAddress(address.getHostName(), address.getPort());
             }
 
-            this.bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECT_TIMEOUT);
-            this.bootstrap.remoteAddress(this.address);
-            final ChannelFuture connectFuture = this.bootstrap.connect();
+            bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECT_TIMEOUT);
+            bootstrap.remoteAddress(address);
+            final ChannelFuture connectFuture = bootstrap.connect();
             connectFuture.addListener(new BootstrapConnectListener());
-            this.pending = connectFuture;
+            pending = connectFuture;
         } catch (final Exception e) {
-            LOG.warn("Failed to connect to {}", this.address, e);
-            this.setFailure(e);
+            LOG.warn("Failed to connect to {}", address, e);
+            setFailure(e);
         }
     }
 
     synchronized void reconnect() {
-        if (this.retryTimer == 0) {
+        if (retryTimer == 0) {
             LOG.debug("Retry timer value is 0. Reconnection will not be attempted");
-            this.setFailure(this.pending.cause());
+            setFailure(pending.cause());
             return;
         }
 
-        final EventLoop loop = this.pending.channel().eventLoop();
+        final EventLoop loop = pending.channel().eventLoop();
         loop.schedule(() -> {
             synchronized (BGPProtocolSessionPromise.this) {
                 if (BGPProtocolSessionPromise.this.peerSessionPresent) {
@@ -107,16 +107,16 @@ public final class BGPProtocolSessionPromise<S extends BGPSession> extends Defau
                 reconnectFuture.addListener(new BootstrapConnectListener());
                 BGPProtocolSessionPromise.this.pending = reconnectFuture;
             }
-        }, this.retryTimer, TimeUnit.SECONDS);
-        LOG.debug("Next reconnection attempt in {}s", this.retryTimer);
+        }, retryTimer, TimeUnit.SECONDS);
+        LOG.debug("Next reconnection attempt in {}s", retryTimer);
     }
 
     @Override
     public synchronized boolean cancel(final boolean mayInterruptIfRunning) {
         closePeerSessionListener();
         if (super.cancel(mayInterruptIfRunning)) {
-            requireNonNull(this.pending);
-            this.pending.cancel(mayInterruptIfRunning);
+            requireNonNull(pending);
+            pending.cancel(mayInterruptIfRunning);
             return true;
         }
 
@@ -126,7 +126,7 @@ public final class BGPProtocolSessionPromise<S extends BGPSession> extends Defau
     @SuppressWarnings("checkstyle:illegalCatch")
     private synchronized void closePeerSessionListener() {
         try {
-            this.listenerRegistration.close();
+            listenerRegistration.close();
         } catch (final Exception e) {
             LOG.debug("Exception encountered while closing peer registry session listener registration", e);
         }
@@ -138,14 +138,14 @@ public final class BGPProtocolSessionPromise<S extends BGPSession> extends Defau
         return super.setSuccess(result);
     }
 
-    private class BootstrapConnectListener implements ChannelFutureListener {
+    private final class BootstrapConnectListener implements ChannelFutureListener {
         @Override
         public void operationComplete(final ChannelFuture channelFuture) throws Exception {
             synchronized (BGPProtocolSessionPromise.this) {
                 LOG.debug("Promise {} connection resolved", BGPProtocolSessionPromise.this);
                 checkState(BGPProtocolSessionPromise.this.pending.equals(channelFuture), "Unexpected promise %s",
                     channelFuture);
-                if (BGPProtocolSessionPromise.this.isCancelled()) {
+                if (isCancelled()) {
                     if (channelFuture.isSuccess()) {
                         LOG.debug("Closing channel for cancelled promise {}", BGPProtocolSessionPromise.this);
                         channelFuture.channel().close();
@@ -170,7 +170,7 @@ public final class BGPProtocolSessionPromise<S extends BGPSession> extends Defau
 
         @Override
         public void onSessionCreated(final IpAddressNoZone ip) {
-            if (ip.equals(this.peerAddress)) {
+            if (ip.equals(peerAddress)) {
                 LOG.debug("Callback for session creation with peer {} received", ip);
                 synchronized (BGPProtocolSessionPromise.this) {
                     BGPProtocolSessionPromise.this.peerSessionPresent = true;
@@ -180,7 +180,7 @@ public final class BGPProtocolSessionPromise<S extends BGPSession> extends Defau
 
         @Override
         public void onSessionRemoved(final IpAddressNoZone ip) {
-            if (ip.equals(this.peerAddress)) {
+            if (ip.equals(peerAddress)) {
                 LOG.debug("Callback for session removal with peer {} received", ip);
                 synchronized (BGPProtocolSessionPromise.this) {
                     BGPProtocolSessionPromise.this.peerSessionPresent = false;
index bfda537920765ffc06b841fcb3f51c4b483e8afb..41eed3acdb9006488857c247abf0e219c4f6e25c 100644 (file)
@@ -194,7 +194,7 @@ public class AbstractRIBTestSetup extends DefaultRibPoliciesMockTest {
         return domTransWrite;
     }
 
-    private static class TestListenerRegistration implements ListenerRegistration<EventListener> {
+    private static final class TestListenerRegistration implements ListenerRegistration<EventListener> {
         @Override
         public EventListener getInstance() {
             return null;
index 764a9597183022c19624a96c4417cf4626b705e6..2442571f3dd01e6aaaa351a6d9e06be9d8c9e49d 100644 (file)
@@ -23,7 +23,7 @@ public class DefaultRIBExtensionProviderContextTest extends AbstractRIBActivator
         assertTrue(ribActivated);
     }
 
-    private class RibActivator implements RIBExtensionProviderActivator {
+    private final class RibActivator implements RIBExtensionProviderActivator {
         @Override
         public List<Registration> startRIBExtensionProvider(final RIBExtensionProviderContext context,
                 final BindingNormalizedNodeSerializer mappingService) {
index 971ce734413c8a556b02f290bba249756a90cbb7..c59f73aad76b568842fec31b8797d57315d353f0 100644 (file)
@@ -50,26 +50,26 @@ public final class PCEPProtocolSessionPromise<S extends PCEPSession> extends Def
         final PCEPProtocolSessionPromise<?> lock = this;
 
         try {
-            LOG.debug("Promise {} attempting connect for {}ms", lock, this.connectTimeout);
-            if (this.address.isUnresolved()) {
-                this.address = new InetSocketAddress(this.address.getHostName(), this.address.getPort());
+            LOG.debug("Promise {} attempting connect for {}ms", lock, connectTimeout);
+            if (address.isUnresolved()) {
+                address = new InetSocketAddress(address.getHostName(), address.getPort());
             }
 
-            this.bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, this.connectTimeout);
-            this.bootstrap.remoteAddress(this.address);
-            final ChannelFuture connectFuture = this.bootstrap.connect();
+            bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout);
+            bootstrap.remoteAddress(address);
+            final ChannelFuture connectFuture = bootstrap.connect();
             connectFuture.addListener(new BootstrapConnectListener());
-            this.pending = connectFuture;
+            pending = connectFuture;
         } catch (RuntimeException e) {
-            LOG.info("Failed to connect to {}", this.address, e);
-            this.setFailure(e);
+            LOG.info("Failed to connect to {}", address, e);
+            setFailure(e);
         }
     }
 
     @Override
     public synchronized boolean cancel(final boolean mayInterruptIfRunning) {
         if (super.cancel(mayInterruptIfRunning)) {
-            this.pending.cancel(mayInterruptIfRunning);
+            pending.cancel(mayInterruptIfRunning);
             return true;
         }
 
@@ -82,14 +82,14 @@ public final class PCEPProtocolSessionPromise<S extends PCEPSession> extends Def
         return super.setSuccess(result);
     }
 
-    private class BootstrapConnectListener implements ChannelFutureListener {
+    private final class BootstrapConnectListener implements ChannelFutureListener {
         @Override
         public void operationComplete(final ChannelFuture cf) {
             synchronized (PCEPProtocolSessionPromise.this) {
                 PCEPProtocolSessionPromise.LOG.debug("Promise {} connection resolved",
                         PCEPProtocolSessionPromise.this);
                 Preconditions.checkState(PCEPProtocolSessionPromise.this.pending.equals(cf));
-                if (PCEPProtocolSessionPromise.this.isCancelled()) {
+                if (isCancelled()) {
                     if (cf.isSuccess()) {
                         PCEPProtocolSessionPromise.LOG.debug("Closing channel for cancelled promise {}",
                                 PCEPProtocolSessionPromise.this);
@@ -105,7 +105,7 @@ public final class PCEPProtocolSessionPromise<S extends PCEPSession> extends Def
                     if (PCEPProtocolSessionPromise.this.retryTimer == 0) {
                         PCEPProtocolSessionPromise.LOG
                                 .debug("Retry timer value is 0. Reconnection will not be attempted");
-                        PCEPProtocolSessionPromise.this.setFailure(cf.cause());
+                        setFailure(cf.cause());
                         return;
                     }
 
index 3512ef8fe93a58cc848f4a8bd638715ce1dc8cff..576c33bb6a0e656549be5a3f6ef35427524e3698 100644 (file)
@@ -189,7 +189,7 @@ public class PCEPSessionImplTest extends AbstractPCEPSessionTest {
         verify(session).closeChannel();
     }
 
-    private static class SimpleExceptionSessionListener extends SimpleSessionListener {
+    private static final class SimpleExceptionSessionListener extends SimpleSessionListener {
         @Override
         public synchronized void onSessionUp(final PCEPSession session) {
             super.onSessionUp(session);