Prevent NullPointerException 74/66274/1
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Wed, 6 Dec 2017 12:54:07 +0000 (13:54 +0100)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Wed, 6 Dec 2017 12:55:45 +0000 (13:55 +0100)
Change-Id: I771ea0d9a19df410e276975ddd2c4302374d0a00
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
bmp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/BmpMonitoringStationImpl.java

index f67f1408f841c3031e6966deceaa155b005477b6..82f5477b87ee4612f0e5b0d3898a85e0136b4c64 100644 (file)
@@ -109,10 +109,13 @@ public final class BmpMonitoringStationImpl implements BmpMonitoringStation, Clu
     public synchronized ListenableFuture<Void> closeServiceInstance() {
         LOG.info("BMP Monitor Singleton Service {} instance closed, Monitor Id {}",
                 getIdentifier().getValue(), this.monitorId.getValue());
-        this.channel.close().addListener((ChannelFutureListener) future -> {
-            Preconditions.checkArgument(future.isSuccess(), "Channel failed to close: %s", future.cause());
-            BmpMonitoringStationImpl.this.sessionManager.close();
-        });
+        if (this.channel != null) {
+            this.channel.close().addListener((ChannelFutureListener) future -> {
+                Preconditions.checkArgument(future.isSuccess(),
+                        "Channel failed to close: %s", future.cause());
+                BmpMonitoringStationImpl.this.sessionManager.close();
+            });
+        }
 
         final DOMDataWriteTransaction wTx = this.domDataBroker.newWriteOnlyTransaction();
         wTx.delete(LogicalDatastoreType.OPERATIONAL, this.yangMonitorId);