Use a singleton list in HwvtepTableReader 40/86140/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 3 Dec 2019 11:06:15 +0000 (12:06 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 3 Dec 2019 11:43:49 +0000 (12:43 +0100)
Rather than allocating a full-blown ArrayList, use only a singleton,
saving some memory.

Change-Id: I7505ae7b061d8a410a8df7ef9458e83c560823e2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepTableReader.java

index 34ab973eadc641daf95988662bcd19de0e6b0e9f..41c53bcb2802e76c29496d6cc985f13bd9dc34df 100644 (file)
@@ -266,12 +266,9 @@ public class HwvtepTableReader {
             selectOperation.where(table.getUuidColumn().getSchema().opEqual(existingUUID));
         }
 
-        ArrayList<Operation> operations = new ArrayList<>();
-        operations.add(selectOperation);
-
         final List<OperationResult> results;
         try {
-            results = connectionInstance.transact(dbSchema, operations).get();
+            results = connectionInstance.transact(dbSchema, Collections.singletonList(selectOperation)).get();
         } catch (InterruptedException | ExecutionException e) {
             LOG.warn("Not able to fetch hardware_vtep table row from device {}",
                 connectionInstance.getConnectionInfo(), e);
@@ -309,7 +306,7 @@ public class HwvtepTableReader {
 
         final List<OperationResult> results;
         try {
-            results = connectionInstance.transact(dbSchema, Lists.newArrayList(selectOperation)).get();
+            results = connectionInstance.transact(dbSchema, Collections.singletonList(selectOperation)).get();
         } catch (InterruptedException | ExecutionException e) {
             LOG.error("Not able to fetch hardware_vtep table row from device {}",
                 connectionInstance.getConnectionInfo(), e);