From 2cfa73206d471041fff18c3f6ff39abad86de6f5 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 13 Jul 2023 07:54:34 +0530 Subject: [PATCH] Fix OSGI service unbinding issue --- .../internal/DeviceManagementDataHolder.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java index a901ffeddf1..3fa8fdc4530 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -118,18 +118,18 @@ public class DeviceManagementDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } public TenantManager getTenantManager() { - return tenantManager; - } - - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); } - this.tenantManager = realmService.getTenantManager(); + return tenantManager; } + + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public DeviceManagementProviderService getDeviceManagementProvider() {