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

Fix NullPointerException when ShortNumberInfo.isPossibleShortNumber is used with a region not in ShortNumberMetadata #718

Closed
wants to merge 1 commit into from

Conversation

giggsey
Copy link
Contributor

@giggsey giggsey commented Jun 17, 2015

Example code:

import com.google.i18n.phonenumbers.*;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;

public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
        PhoneNumber phoneNumber = null;
        PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
        phoneNumber = phoneNumberUtil.getExampleNumber("NE");

        ShortNumberInfo shortNumberInfo = ShortNumberInfo.getInstance();

        shortNumberInfo.isPossibleShortNumber(phoneNumber);

    }

}

NE is a valid region, and exists in PhoneNumberMetadata. This means that the check in getRegionCodesForCountryCode returns the correct region code.

It then loops through, loading the metadata for each region, but doesn't actually check whether the metadata exists.

Credit to @RuslanGetmansky via giggsey/libphonenumber-for-php#68

I haven't updated any unit tests for this, but I can do if needed (my Java is not very good)

@dlyongemallo dlyongemallo self-assigned this Jun 23, 2015
@dlyongemallo
Copy link
Contributor

Thanks for reporting this, it'll be fixed in the next release.

@andyst
Copy link
Collaborator

andyst commented Jun 29, 2015

Thanks! This is in libphonenumber 7.0.7.

@andyst andyst closed this Jun 29, 2015
@giggsey
Copy link
Contributor Author

giggsey commented Jun 29, 2015

Is it?

ShortnumberInfo.java hasn't changed since Dec 2014.

@andyst
Copy link
Collaborator

andyst commented Jun 29, 2015

Thanks! Looks like we didn't make the change on github yet. Reopening.

@andyst andyst reopened this Jun 29, 2015
@giggsey
Copy link
Contributor Author

giggsey commented Jul 1, 2015

I can see this has been fixed by #731, closing this one.

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