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

Offen
#589 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
java
Bereich
api

Rechercherichtung

Reproduziere den Fall eines fehlenden Endpunkts aus dem Beispiel ContainerInstanceClient.builder().build(provider) und verfolge den Stacktrace durch ClientCall.method und ContainerInstanceClient.createContainerInstance. Bestätige das erwartete Verhalten eines frühen Fehlschlags im Vergleich zum Verhalten von 2.x und prüfe die Beispiele in der Oracle-Dokumentation auf Hinweise zum Endpunkt. Erledigt ist die Aufgabe, wenn der fehlende Endpunkt keine null-httpClient-Exception mehr verursacht und die dokumentierte Verwendung eindeutig ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

SDK

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.

Vorherrschende Sprache
Java
Sterne
243
Forks
171
Ø Merge
5 Min.
Gemergte PRs (30 T.)
4

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus oracle/oci-java-sdk

Alle Issues in oracle/oci-java-sdk

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.