ONOS-6205, DistributedMeterStore contains several memory leak when storing CompletableFutures in a map but failing to remove them when the futures are completedexceptionally.
Change-Id: I4690bc4b93de7174e1f185fcc63fc7eca068728d
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/meter/impl/DistributedMeterStore.java b/incubator/store/src/main/java/org/onosproject/incubator/store/meter/impl/DistributedMeterStore.java
index dd1e81a..1cc68a6 100644
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/meter/impl/DistributedMeterStore.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/meter/impl/DistributedMeterStore.java
@@ -180,6 +180,7 @@
try {
meters.put(key, data);
} catch (StorageException e) {
+ futures.remove(key);
future.completeExceptionally(e);
}
@@ -203,6 +204,7 @@
}
updateMeterIdAvailability(meter.deviceId(), meter.id(), true);
} catch (StorageException e) {
+ futures.remove(key);
future.completeExceptionally(e);
}
@@ -246,6 +248,7 @@
future.complete(MeterStoreResult.fail(MeterFailReason.INVALID_METER));
}
} catch (StorageException e) {
+ futures.remove(key);
future.completeExceptionally(e);
}
return future;