Misleading exception when endpoint isn't configured. java.lang.NullPointerException: "this.httpClient" is null
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 243
- Forks
- 171
- Avg merge
- 30m
- Merged PRs (30d)
- 4
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the missing-endpoint case from the ContainerInstanceClient.builder().build(provider) example and follow the stack trace through ClientCall.method and ContainerInstanceClient.createContainerInstance. Confirm the expected early failure behavior against the 2.x behavior, and check the Oracle documentation examples for endpoint guidance. Done means the missing endpoint no longer produces a null httpClient exception and the documented usage is clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100