microsoftgraph / microsoftgraph/msgraph-sdk-java

null batchResponse when POSTing a batch request.

未关闭
#2,255 3 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@Ndiritu 已经在做这个了。

开始于 2024年12月19日。

type:bug
主要语言
Java
星标
444
派生
154
平均合并
18 小时 28 分钟
30 天内合并 PR
4

描述

Describe the bug
Caused by: java.lang.NullPointerException: The following parameter cannot be null: batchResponse
	at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]
	at com.microsoft.graph.core.content.BatchResponseContent.<init>(BatchResponseContent.java:42) ~[microsoft-graph-core-3.2.1.jar:?]
	at com.microsoft.graph.core.requests.BatchRequestBuilder.post(BatchRequestBuilder.java:53) ~[microsoft-graph-core-3.2.1.jar:?]
	at com.microsoft.graph.serviceclient.CustomBatchRequestBuilder.post(CustomBatchRequestBuilder.java:41) ~[microsoft-graph-6.16.0.jar:?]
	at com.microsoft.graph.core.requests.BatchRequestBuilder.post(BatchRequestBuilder.java:67) ~[microsoft-graph-core-3.2.1.jar:?]
	at com.microsoft.graph.serviceclient.CustomBatchRequestBuilder.post(CustomBatchRequestBuilder.java:53) ~[microsoft-graph-6.16.0.jar:?]
2024-11-21T16:05:58 WARNING [TOMCAT] okhttp3.internal.platform.Platform log okhttp3.OkHttpClient - A connection to https://graph.microsoft.com/ was leaked. Did you forget to close a response body? To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);

Our code started throwing a null pointer exception as shown in the logs. The code and requests normally run fine, however this error seems to have randomly occurred. Once we saw this error all subsequent requests to Azure also failed until the process was restarted.

Under what circumstances could this happen?

Expected behavior

Requests complete successfully. Failed requests should throw an ApiException?

How to reproduce

This does not occur under normal circumstances - the following code usually works fine.

We have seen the same error on two different underlying requests, wrapped in batch requests.
mGraphClient.users().byUserId(x).memberOf().graphGroup() and mGraphClient.groups().getByIds()

An example:

ClientSecretCredential vCredential = new ClientSecretCredentialBuilder().clientId(mClientId).tenantId(mTenantId).clientSecret(mClientSecret).build();
mGraphClient = new GraphServiceClient(vCredential, "https://graph.microsoft.com/.default");

-----
BatchRequestContentCollection vBatchRequest = new BatchRequestContentCollection(mGraphClient);
for (String vId : pIds) {
  RequestInformation vRequestInfo = mGraphClient.users().byUserId(vId).memberOf().graphGroup().toGetRequestInformation(requestConfiguration -> {
	  requestConfiguration.queryParameters.select = new String[] { ID };
	  requestConfiguration.queryParameters.top = MAX_PAGE_SIZE;
  });
  vBatchRequest.addBatchRequestStep(vRequestInfo);
}

BatchResponseContentCollection vBatchResponse = mGraphClient.getBatchRequestBuilder().post(vBatchRequest, null);
SDK Version

6.16.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

贡献指南

打开贡献指南

从这里开始

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

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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