Skip to content

Misleading exception when endpoint isn't configured. java.lang.NullPointerException: "this.httpClient" is null #589

Open
@e3ndr

Description

@e3ndr

This is a low-priority issue, but when calling the API without an endpoint the SDK appears to not be configuring the http client, rather than throwing an error early-on informing the user that an endpoint is required. This only occurs on 3.x, 2.x properly throws an error for the missing endpoint early-on.

Code to reproduce:

        this.containerClient = ContainerInstanceClient
            .builder()
            // .endpoint("https://compute-containers.us-ashburn-1.oci.oraclecloud.com") // Omit to reproduce.
            .build(provider);
            
        // Call any API now.

Stacktrace:

Caused by: java.lang.NullPointerException: Cannot invoke "com.oracle.bmc.http.client.HttpClient.createRequest(com.oracle.bmc.http.client.Method)" because "this.httpClient" is null
 	at com.oracle.bmc.http.internal.ClientCall.method(ClientCall.java:173)
 	at com.oracle.bmc.containerinstances.ContainerInstanceClient.createContainerInstance(ContainerInstanceClient.java:202)
 	... 5 more

It should also be noted that the Oracle docs that give the SDK copy/paste examples don't tell you that you need to configure the endpoint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    SDKIssue pertains to the SDK itself and not specific to any service

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions