Skip to content

NPE inside CustomTabIntentBuilder #315

Description

@hrafnthor

Hi,

I've had a fatal exception reported during usage of CustomTabIntentBuilder:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean o.ᴸ.ˊ(android.net.Uri, android.os.Bundle, java.util.List)' on a null object reference
       at net.openid.appauth.browser.CustomTabManager.createSession(CustomTabManager.java:151)
       at net.openid.appauth.browser.CustomTabManager.createTabBuilder(CustomTabManager.java:114)
       at net.openid.appauth.AuthorizationService.createCustomTabsIntentBuilder(AuthorizationService.java:127)
       at <my-package>.auth.AuthRepository$1.createAuthenticationIntent(AuthRepository.java:100)

According to the stacktrace, the session created in the AppAuth's CustomTabManager.createSession() is null, when being accessed inside the later if statement:

  /**
     * Creates a {@link android.support.customtabs.CustomTabsSession custom tab session} for
     * use with a custom tab intent, with optional callbacks and optional list of URIs that may
     * be requested. The URI list should be ordered such that the most likely URI to be requested
     * is first. If no custom tab supporting browser is available, this will return {@code null}.
     */
    @WorkerThread
    @Nullable
    public CustomTabsSession createSession(
            @Nullable CustomTabsCallback callbacks,
            @Nullable Uri... possibleUris) {
        CustomTabsClient client = getClient();
        if (client == null) {
            return null;
        }

        CustomTabsSession session = client.newSession(callbacks);

        if (possibleUris != null && possibleUris.length > 0) {
            List<Bundle> additionalUris = UriUtil.toCustomTabUriBundle(possibleUris, 1);
            session.mayLaunchUrl(possibleUris[0], null, additionalUris);
        }

        return session;
    }

Here a null pointer check might be required before accessing the session object?

Or is this normal behaviour during some edge case I have simply overlooked?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions