-
Notifications
You must be signed in to change notification settings - Fork 22
NPE check for Password and Account Name field #384
base: MAS-2.1.00
Are you sure you want to change the base?
Changes from 3 commits
3539bf8
5e4d89e
cc6e418
43d9ef5
fae84fe
ff87134
e1dac15
1f70116
37ea576
13dd503
b006774
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,16 +52,18 @@ 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want to put some logging in this block also. |
||
String savedPassword = identifier.toString(); | ||
if (password.equals(savedPassword)) { | ||
if (password != null && password.equals(savedPassword)) { | ||
mAccount = account; | ||
}else { | ||
// - case migration from old AccountManagerStoreDataSource | ||
mAccount = null; | ||
identifier = new SharedStorageIdentifier(); | ||
} | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might be throwing the exception for name mismatch. It's a mistake. We need to rewrite the logic like below: accountName is invariant to the loop. Hence, a null check for the accountName should be done outside the for-loop.
|
||
throw new IllegalArgumentException("Invalid parameters, Account name cannot be null"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [optional], "Account name cannot be null" is sufficient here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
} | ||
|
||
|
@@ -223,4 +225,4 @@ private String proxyKey(String key){ | |
|
||
return retVal; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply synchronization to the block that consists of the below logic:
synchronized {
}