From dcc804880dc7193593c94975e9e2aaa6078bed8c Mon Sep 17 00:00:00 2001 From: abhisheknaidu-462 Date: Wed, 13 May 2020 16:05:45 +0530 Subject: [PATCH 1/3] 31804215 - Error AccountManagerUtil MAS foundation Android SDK- Null pointer exception handled --- .../ca/mas/core/storage/sharedstorage/AccountManagerUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mas-foundation/src/main/java/com/ca/mas/core/storage/sharedstorage/AccountManagerUtil.java b/mas-foundation/src/main/java/com/ca/mas/core/storage/sharedstorage/AccountManagerUtil.java index 97de61665..659fc515a 100644 --- a/mas-foundation/src/main/java/com/ca/mas/core/storage/sharedstorage/AccountManagerUtil.java +++ b/mas-foundation/src/main/java/com/ca/mas/core/storage/sharedstorage/AccountManagerUtil.java @@ -52,7 +52,7 @@ public AccountManagerUtil(Context context, String accountName, boolean sharedSto //Attempt to retrieve the account Account[] accounts = mAccountManager.getAccountsByType(accountType); for (Account account : accounts) { - if (accountName.equals(account.name)) { + if (accountName != null && accountName.equals(account.name)) { String password = mAccountManager.getPassword(account); String savedPassword = identifier.toString(); if (password.equals(savedPassword)) { From 5b572b8e38b8e753486c9174550f643a95bd8d56 Mon Sep 17 00:00:00 2001 From: abhisheknaidu-462 Date: Fri, 15 May 2020 02:51:08 +0530 Subject: [PATCH 2/3] Error AccountManagerUtil MAS foundation Android SDK - Null pointer exception handled --- .../java/com/ca/mas/connecta/client/MASConnectaManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mas-connecta/src/main/java/com/ca/mas/connecta/client/MASConnectaManager.java b/mas-connecta/src/main/java/com/ca/mas/connecta/client/MASConnectaManager.java index 677416fd8..6c6bdd149 100755 --- a/mas-connecta/src/main/java/com/ca/mas/connecta/client/MASConnectaManager.java +++ b/mas-connecta/src/main/java/com/ca/mas/connecta/client/MASConnectaManager.java @@ -68,6 +68,8 @@ private MqttConnecta getMqttConnecta() { if ((connectOptions == null) || (connectOptions.getServerURIs() == null)) { return new GatewayMqttConnecta(); } else { + if (clientId == null) + throw new NullPointerException("clientId"); return new PublicMqttConnecta((clientId)); } } From 2a2e22253048fb13ac9fd9b12faab67f56ef4a9c Mon Sep 17 00:00:00 2001 From: abhisheknaidu-462 Date: Fri, 15 May 2020 17:15:22 +0530 Subject: [PATCH 3/3] 1) Added null pointer check for password field. 2) Removed null pointer check for clientId --- .../java/com/ca/mas/connecta/client/MASConnectaManager.java | 2 -- .../ca/mas/core/storage/sharedstorage/AccountManagerUtil.java | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mas-connecta/src/main/java/com/ca/mas/connecta/client/MASConnectaManager.java b/mas-connecta/src/main/java/com/ca/mas/connecta/client/MASConnectaManager.java index 6c6bdd149..677416fd8 100755 --- a/mas-connecta/src/main/java/com/ca/mas/connecta/client/MASConnectaManager.java +++ b/mas-connecta/src/main/java/com/ca/mas/connecta/client/MASConnectaManager.java @@ -68,8 +68,6 @@ private MqttConnecta getMqttConnecta() { if ((connectOptions == null) || (connectOptions.getServerURIs() == null)) { return new GatewayMqttConnecta(); } else { - if (clientId == null) - throw new NullPointerException("clientId"); return new PublicMqttConnecta((clientId)); } } diff --git a/mas-foundation/src/main/java/com/ca/mas/core/storage/sharedstorage/AccountManagerUtil.java b/mas-foundation/src/main/java/com/ca/mas/core/storage/sharedstorage/AccountManagerUtil.java index 659fc515a..954477217 100644 --- a/mas-foundation/src/main/java/com/ca/mas/core/storage/sharedstorage/AccountManagerUtil.java +++ b/mas-foundation/src/main/java/com/ca/mas/core/storage/sharedstorage/AccountManagerUtil.java @@ -55,9 +55,9 @@ public AccountManagerUtil(Context context, String accountName, boolean sharedSto if (accountName != null && accountName.equals(account.name)) { String password = mAccountManager.getPassword(account); String savedPassword = identifier.toString(); - if (password.equals(savedPassword)) { + if (password != null && password.equals(savedPassword)) { mAccount = account; - }else { + } else { // - case migration from old AccountManagerStoreDataSource mAccount = null; identifier = new SharedStorageIdentifier();