From 5de4f4424f1dd0b422a3682ef905cfd7d71b29d9 Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Wed, 3 Jul 2024 15:41:40 +0100 Subject: Fix sonar issue in performance test ResourceMeter Replace busy loop with await().until as suggested by sonar Issue-ID: CPS-89 Signed-off-by: danielhanrahan Change-Id: Ic6c870c419a67708082ceb05ef3ccba884ae375e --- .../src/test/java/org/onap/cps/integration/ResourceMeter.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'integration-test/src') diff --git a/integration-test/src/test/java/org/onap/cps/integration/ResourceMeter.java b/integration-test/src/test/java/org/onap/cps/integration/ResourceMeter.java index f8a2ecb4df..46bfcf69e6 100644 --- a/integration-test/src/test/java/org/onap/cps/integration/ResourceMeter.java +++ b/integration-test/src/test/java/org/onap/cps/integration/ResourceMeter.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation + * Copyright (C) 2023-2024 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. @@ -20,6 +20,8 @@ package org.onap.cps.integration; +import static org.awaitility.Awaitility.await; + import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; import java.lang.management.MemoryPoolMXBean; @@ -71,7 +73,7 @@ public class ResourceMeter { static void performGcAndWait() { final long gcCountBefore = getGcCount(); System.gc(); - while (getGcCount() == gcCountBefore) {} + await().until(() -> getGcCount() > gcCountBefore); } private static long getGcCount() { @@ -94,4 +96,3 @@ public class ResourceMeter { .forEach(MemoryPoolMXBean::resetPeakUsage); } } - -- cgit 1.2.3-korg