Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JBIDE-21338 - simple npe check when loading credentials model #471

Closed

Conversation

robstryker
Copy link
Member

targeted to beta2

@fbricon
Copy link
Member

fbricon commented Dec 16, 2015

+1

@robstryker
Copy link
Member Author

pushed after rebase

@robstryker robstryker closed this Dec 23, 2015
@@ -60,7 +60,7 @@ public CredentialDomain(Preferences pref) throws BackingStoreException {

credentials = new HashMap<String, String>();
String usersList = pref.get(PROPERTY_USER_LIST, (String)null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now it is too late, but why not this:

...
        credentials = new HashMap<String, String>();
        String usersList = pref.get(PROPERTY_USER_LIST, "");
        if( !usersList.isEmpty()) {
            String[] users = usersList.split("\n");
            for( int i = 0; i < users.length; i++ ) {
                credentials.put(users[i], NOT_LOADED_PASSWORD);
...

no null checks, no extra ternary operator.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that would have worked as well, but I prefer to actually know whether the string was null (ie not set) or empty (ie previously persisted as an empty list) so that I can alter behavior based on those two conditions if I need to later. Having the default be the empty string makes me unable to tell the difference between unset and set-as-empty. Anyway, it's already been pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants