Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is GraphServiceClient threadsafe? #2224

Open
siddhartha-ghosh opened this issue Nov 14, 2024 · 2 comments
Open

Is GraphServiceClient threadsafe? #2224

siddhartha-ghosh opened this issue Nov 14, 2024 · 2 comments

Comments

@siddhartha-ghosh
Copy link

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).

@siddhartha-ghosh siddhartha-ghosh added the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Nov 14, 2024
@Ndiritu Ndiritu added Status: Needs Investigation and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Dec 2, 2024
@Ndiritu
Copy link
Contributor

Ndiritu commented Dec 2, 2024

Great question @siddhartha-ghosh. I will get back soon after some investigations

@siddhartha-ghosh
Copy link
Author

Hi @Ndiritu , is there any update on this issue? Thanks in advance.
Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants