From f425a0c869c546589dcb1aace9f51f7670720c61 Mon Sep 17 00:00:00 2001 From: osh Date: Wed, 10 May 2023 11:21:33 +1000 Subject: [PATCH] Fix cache issue when billing cache is enabled --- .../device/mgt/jaxrs/service/impl/MetadataServiceImpl.java | 1 + .../wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java index 398a6427c1..47a3fd295d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java @@ -110,6 +110,7 @@ public class MetadataServiceImpl implements MetadataService { RequestValidationUtil.validateMetadata(metadata); try { Metadata createdMetadata = DeviceMgtAPIUtils.getMetadataManagementService().createMetadata(metadata); + DeviceManagerUtil.removeBillingCache(); return Response.status(Response.Status.CREATED).entity(createdMetadata).build(); } catch (MetadataKeyAlreadyExistsException e) { String msg = "Metadata entry metaKey:" + metadata.getMetaKey() + " is already exist."; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index 37aa456130..4dc0b42551 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -701,7 +701,8 @@ public final class DeviceManagerUtil { */ public static void removeBillingCache() { CacheManager manager = getCacheManager(); - manager.removeCache(DeviceManagementConstants.BILLING_CACHE); + Cache cache = manager.getCache(DeviceManagementConstants.BILLING_CACHE); + cache.removeAll(); } /** -- 2.36.3