Simplify lambdas
[openflowplugin.git] / applications / southbound-cli / src / main / java / org / opendaylight / openflowplugin / applications / southboundcli / ReconciliationServiceImpl.java
index cab6b27b8c0896ecfc0da06e53004b2f9f4b9a4d..93a0674238887457e0fe4e762732c9cfd208ce8c 100644 (file)
@@ -104,7 +104,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo
         SettableFuture<RpcResult<ReconcileOutput>> result = SettableFuture.create();
         List<Long> nodeList = getAllNodes();
         List<Long> nodesToReconcile = reconcileAllNodes ? nodeList :
-                inputNodes.stream().distinct().map(node -> node.longValue()).collect(Collectors.toList());
+                inputNodes.stream().distinct().map(BigInteger::longValue).collect(Collectors.toList());
         if (nodesToReconcile.size() > 0) {
             List<Long> unresolvedNodes =
                     nodesToReconcile.stream().filter(node -> !nodeList.contains(node)).collect(Collectors.toList());
@@ -141,21 +141,18 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo
         InstanceIdentifier<ReconciliationStateList> instanceIdentifier = InstanceIdentifier
                 .builder(ReconciliationState.class).child(ReconciliationStateList.class,
                         new ReconciliationStateListKey(new BigInteger(String.valueOf(nodeId)))).build();
-        ReadOnlyTransaction tx = broker.newReadOnlyTransaction();
-        try {
+        try (ReadOnlyTransaction tx = broker.newReadOnlyTransaction()) {
             return tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier).get();
 
         } catch (InterruptedException  | ExecutionException e) {
             LOG.error("Exception while reading reconciliation state for {}", nodeId, e);
-        } finally {
-            tx.close();
         }
         return Optional.absent();
     }
 
     private ListenableFuture<RpcResult<ReconcileOutput>> buildErrorResponse(String msg) {
         SettableFuture<RpcResult<ReconcileOutput>> result = SettableFuture.create();
-        LOG.error(msg);
+        LOG.error("Error {}", msg);
         RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.PROTOCOL, "reconcile", msg);
         result.set(RpcResultBuilder.<ReconcileOutput>failed().withRpcError(error).build());
         return result;
@@ -163,7 +160,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo
 
     private List<Long> getAllNodes() {
         List<OFNode> nodeList = ShellUtil.getAllNodes(broker);
-        List<Long> nodes = nodeList.stream().distinct().map(node -> node.getNodeId()).collect(Collectors.toList());
+        List<Long> nodes = nodeList.stream().distinct().map(OFNode::getNodeId).collect(Collectors.toList());
         return nodes;
     }