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 28cc7ba..7124a1f 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
@@ -202,6 +202,7 @@
try {
meters.put(key, data);
} catch (StorageException e) {
+ futures.remove(key);
future.completeExceptionally(e);
}
// Done, return the future
@@ -226,6 +227,7 @@
future.complete(MeterStoreResult.success());
}
} catch (StorageException e) {
+ futures.remove(key);
future.completeExceptionally(e);
}
// Done, return the future
@@ -268,6 +270,7 @@
future.complete(MeterStoreResult.fail(MeterFailReason.INVALID_METER));
}
} catch (StorageException e) {
+ futures.remove(key);
future.completeExceptionally(e);
}
return future;