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

未关闭
#589 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
java
领域
api

调研方向

复现 ContainerInstanceClient.builder().build(provider) 示例中的端点缺失情况,并沿着 ClientCall.method 和 ContainerInstanceClient.createContainerInstance 跟踪堆栈。对照 2.x 的行为,确认预期的提前失败行为,并检查 Oracle 文档中的示例以获取端点方面的指导。完成的标准是:缺少端点时不再产生 null httpClient 异常,且文档中的用法清晰明确。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Java
星标
243
派生
171
平均合并
5 分钟
30 天内合并 PR
4

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

oracle/oci-java-sdk 的其他 Issue

查看 oracle/oci-java-sdk 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。