Handled interrupted exception sonar fix
[appc.git] / appc-adapters / appc-dmaap-adapter / appc-dmaap-adapter-bundle / src / main / java / org / onap / appc / adapter / messaging / dmaap / impl / DmaapProducerImpl.java
index 409dbeb..efff18e 100644 (file)
@@ -6,6 +6,8 @@
  * ================================================================================
  * Copyright (C) 2017 Amdocs
  * =============================================================================
+ * Modifications Copyright (C) 2019 IBM
+ * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -186,11 +188,14 @@ public class DmaapProducerImpl implements Producer {
         }
         LOG.debug("Closing Dmaap producer clients....");
         for (MRBatchingPublisher client : clients) {
-            try {
-                client.close(1, TimeUnit.SECONDS);
-            } catch (IOException | InterruptedException e) {
-                LOG.warn(String.format("Failed to cleanly close Dmaap connection for [%s]", client), e);
-            }
+          try {
+            client.close(1, TimeUnit.SECONDS);
+          } catch (InterruptedException e) {
+            LOG.warn(String.format("Failed to cleanly close Dmaap connection for [%s]", client), e);
+            Thread.currentThread().interrupt();
+          } catch (IOException e) {
+            LOG.warn(String.format("Failed to cleanly close Dmaap connection for [%s]", client), e);
+          }
         }
     }