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 398a6427c1f..47a3fd295d4 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 37aa4561304..4dc0b42551c 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(); } /**