diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java index d52115a83..472589e6c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java @@ -335,7 +335,7 @@ public class AndroidDeviceManager implements DeviceManager { List mobileDevices = daoFactory.getMobileDeviceDAO().getAllMobileDevices(); if (mobileDevices != null) { - devices = new ArrayList<>(); + devices = new ArrayList<>(mobileDevices.size()); for (MobileDevice mobileDevice : mobileDevices) { devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice)); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java index ada8eb7d3..6b29e8486 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java @@ -64,7 +64,7 @@ public class AndroidFeatureManager implements FeatureManager { @Override public boolean addFeatures(List features) throws DeviceManagementException { - List mobileFeatures = new ArrayList(); + List mobileFeatures = new ArrayList(features.size()); for (Feature feature : features) { mobileFeatures.add(MobileDeviceManagementUtil.convertToMobileFeature(feature)); } @@ -96,9 +96,9 @@ public class AndroidFeatureManager implements FeatureManager { @Override public List getFeatures() throws DeviceManagementException { - List featureList = new ArrayList(); try { List mobileFeatures = featureDAO.getAllFeatures(); + List featureList = new ArrayList(mobileFeatures.size()); for (MobileFeature mobileFeature : mobileFeatures) { featureList.add(MobileDeviceManagementUtil.convertToFeature(mobileFeature)); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java index 0a87cd668..ced47139f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java @@ -61,8 +61,6 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService { if (compliancePayload == null || policy == null) { return complianceData; } - List complianceFeatures = new ArrayList(); - List nonComplianceFeatures = new ArrayList<>(); String compliancePayloadString = new Gson().toJson(compliancePayload); // Parsing json string to get compliance features. JsonElement jsonElement; @@ -75,6 +73,8 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService { JsonArray jsonArray = jsonElement.getAsJsonArray(); Gson gson = new Gson(); ComplianceFeature complianceFeature; + List complianceFeatures = new ArrayList(jsonArray.size()); + List nonComplianceFeatures = new ArrayList<>(); for (JsonElement element : jsonArray) { complianceFeature = gson.fromJson(element, ComplianceFeature.class); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java index f3ed7b8b3..e49e14d32 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java @@ -43,7 +43,7 @@ public class GCMService { } public void sendNotification(String messageData, Device device) { - List devices = new ArrayList<>(); + List devices = new ArrayList<>(1); devices.add(device); GCMResult result = GCMUtil.sendWakeUpCall(messageData, devices); if (result.getStatusCode() != 200) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java index 12db04ec5..b00ae9639 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java @@ -123,6 +123,9 @@ public class GCMUtil { //Set device reg-ids JsonArray regIds = new JsonArray(); for (String regId : registrationIds) { + if (regId == null && regId.isEmpty()) { + continue; + } regIds.add(new JsonPrimitive(regId)); } @@ -131,7 +134,7 @@ public class GCMUtil { } private static List getGCMTokens(List devices) { - List tokens = new ArrayList<>(); + List tokens = new ArrayList<>(devices.size()); for (Device device : devices) { tokens.add(getGCMToken(device.getProperties())); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index ab7d451a0..a9a7d9d6a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -193,7 +193,7 @@ public class WindowsDeviceManager implements DeviceManager { WindowsDAOFactory.openConnection(); List mobileDevices = daoFactory.getMobileDeviceDAO().getAllMobileDevices(); if (mobileDevices != null) { - devices = new ArrayList<>(); + devices = new ArrayList<>(mobileDevices.size()); for (MobileDevice mobileDevice : mobileDevices) { devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice)); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsFeatureManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsFeatureManager.java index 0dca8b5d6..00e1d5e00 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsFeatureManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsFeatureManager.java @@ -58,7 +58,7 @@ public class WindowsFeatureManager implements FeatureManager { @Override public boolean addFeatures(List features) throws DeviceManagementException { - List mobileFeatures = new ArrayList(); + List mobileFeatures = new ArrayList(features.size()); for (Feature feature : features) { mobileFeatures.add(MobileDeviceManagementUtil.convertToMobileFeature(feature)); } @@ -92,10 +92,10 @@ public class WindowsFeatureManager implements FeatureManager { @Override public List getFeatures() throws DeviceManagementException { - List featureList = new ArrayList(); try { WindowsDAOFactory.openConnection(); List mobileFeatures = featureDAO.getAllFeatures(); + List featureList = new ArrayList(mobileFeatures.size()); for (MobileFeature mobileFeature : mobileFeatures) { featureList.add(MobileDeviceManagementUtil.convertToFeature(mobileFeature)); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java index edecd3a76..73612a365 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java @@ -165,7 +165,7 @@ public class MobileDeviceManagementUtil { public static List getMobileOperationIdsFromMobileDeviceOperations( List mobileDeviceOperationMappings) { - List mobileOperationIds = new ArrayList(); + List mobileOperationIds = new ArrayList(mobileDeviceOperationMappings.size()); for (MobileDeviceOperationMapping mobileDeviceOperationMapping : mobileDeviceOperationMappings) { mobileOperationIds.add(mobileDeviceOperationMapping.getOperationId()); } diff --git a/pom.xml b/pom.xml index 9f5205d74..2de7f4f9b 100644 --- a/pom.xml +++ b/pom.xml @@ -577,7 +577,7 @@ 4.6.0 - 5.0.5 + 5.0.7 4.5.0