Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Is GraphServiceClient threadsafe?

Open
#2,224 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Quiet
Tech stack
java
Domain
api

Research direction

Start with the linked Microsoft Graph Java app-only tutorial and the GraphServiceClient usage relevant to microsoft-graph 6.20.0 and azure-identity 1.14.1. Check the repository documentation and client implementation for guidance on sharing one instance across threads. Done means clearly documenting whether sharing is supported and whether callers need synchronization.

Written by the indexing model from the issue text.

Description

Status: Needs Investigation

Hi,

I am using msgraph sdk to get 'User' details in an application. Initialized the GraphServiceClient for app-only authentication as specified in the tutorial: https://learn.microsoft.com/en-us/graph/tutorials/java-app-only?tabs=aad&tutorial-step=3.

I want to query the 'users' using certain filter and select criteria, e.g.

_appClient.users().get(requestConfig -> {
        requestConfig.queryParameters.filter = "displayName startsWith \'A\'";
        requestConfig.queryParameters.select = new String[] { "displayName", "id", "mail" };
        requestConfig.queryParameters.top = 25;
        requestConfig.queryParameters.orderby = new String[] { "displayName" };
    });

However, this request may happen from the context of different threads.
My queries are:

  • Does each thread need to instantiate GraphServiceClient separately, or, can we initialize once and share across threads?
  • If _appClient (i.e the instance of GraphServiceClient) can be shared, is it thread-safe or do we need to synchronize access to it?

Any insight will be helpful.

The following artifact versions are used: microsoft-graph (v 6.20.0) and azure-identity (1.14.1).

Dominant language
Java
Stars
444
Forks
154
Avg merge
18h 28m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoftgraph/msgraph-sdk-java

All issues in microsoftgraph/msgraph-sdk-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.