In the Java Graph Core SDK the method getBatchRequestContent() in class BatchRequestContent is using PipedInputStream/PipedOutputStream in a single thread which leads to a deadlock.

Udo Woitek 0 Reputation points
2024-03-07T16:35:50.07+00:00

When posting a BatchRequest with the Java Graph Core library (3.1.5), the BatchRequestContent class involved is using a pair of PipedInputStream and PipedOutputStream to provide the POST content as an InputStream.

PipedInputStream and PipedOutputStream are created in the same thread, which (according to the JavaDoc of PipedInputStream) may lead to a deadlock.

That's exactly what happens currently with my code. What's the reason to use these stream classes instead of just creating a simple ByteArrayInputStream using the content of the ByteArrayOutputStream written to by the JsonWriter?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,446 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Carolyne-3676 201 Reputation points
    2024-03-11T14:32:49.51+00:00

    Your suggestion to use a ByteArrayInputStream seems like a viable workaround. You could try modify it manually in the local environment and see if it resolves the deadlock issue.

    Ultimately. I would be recommend that you file this issue in the official Microsoft Graph SDK GitHub repository. for the SDK team to review and investigate it. They may provide a fix or suggest another workaround.

    You can create a new issue here: Microsoft Graph SDK GitHub Repository. Be sure to include all relevant details and code samples.

    0 comments No comments