Fix CI Cent OS 8 configuration issue (workaround)
[transportpce.git] / renderer / src / test / java / org / opendaylight / transportpce / renderer / utils / TransactionUtils.java
index 9ba7c51f9cfabca3745e99ff2f028815c7826c4d..62385266ce483b6808f42d5cd532ae06b5b74f97 100644 (file)
@@ -24,7 +24,7 @@ public final class TransactionUtils {
 
     }
 
-    @SuppressWarnings({ "unchecked", "deprecation", "rawtypes" })
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     // deviceTx.put needs the "true" boolean parameter at the end in order to not compromise the Junit test suite
     // FIXME check if the InstanceIdentifier raw type can be avoided
     // Raw types use are discouraged since they lack type safety.
@@ -40,7 +40,7 @@ public final class TransactionUtils {
         if (!deviceTxFuture.get().isPresent()) {
             return false;
         }
-        DeviceTransaction deviceTx = deviceTxFuture.get().get();
+        DeviceTransaction deviceTx = deviceTxFuture.get().orElseThrow();
         deviceTx.merge(logicalDatastoreType, instanceIdentifier, object);
         deviceTx.commit(Timeouts.DEVICE_WRITE_TIMEOUT, Timeouts.DEVICE_WRITE_TIMEOUT_UNIT).get();
         return true;
@@ -53,16 +53,10 @@ public final class TransactionUtils {
             throws ExecutionException, InterruptedException {
         Future<Optional<DeviceTransaction>> deviceTxFuture =
                 deviceTransactionManager.getDeviceTransaction(nodeId);
-        if (!deviceTxFuture.get().isPresent()) {
-            return null;
-        }
-        DeviceTransaction deviceTx = deviceTxFuture.get().get();
+        DeviceTransaction deviceTx = deviceTxFuture.get().orElseThrow(null);
         Optional<? extends DataObject> readOpt
                 = deviceTx.read(logicalDatastoreType, instanceIdentifier).get();
-        if (!readOpt.isPresent()) {
-            return null;
-        }
-        return readOpt.get();
+        return readOpt.orElseThrow(null);
     }
 
 }