Skip to content

PatternSyntaxException: GraphServiceClient constructor fails on Android with sdk 6.x #1851

@slowcar

Description

@slowcar

I am trying to update the graph sdk from 5.80.0 to 6.3.0 on Android following the upgrade guide.

When trying to initialize the GraphServiceClient i get an exception.
This is my (simplified) code:

OkHttpClient okHttpClient = new OkHttpClient();
BaseBearerTokenAuthenticationProvider authProvider = new BaseBearerTokenAuthenticationProvider(new AccessTokenProvider() {
	@NonNull
	@Override
	public String getAuthorizationToken(@NonNull URI uri, Map<String, Object> additionalAuthenticationContext) {
		return "";
	}
	@NonNull
	@Override
	public AllowedHostsValidator getAllowedHostsValidator() {
		//list of allowed hosts from AzureIdentityAccessTokenProvider
		return new AllowedHostsValidator("graph.microsoft.com", "graph.microsoft.us", "dod-graph.microsoft.us", "graph.microsoft.de", "microsoftgraph.chinacloudapi.cn", "canary.graph.microsoft.com");
	}
});
GraphServiceClient graphServiceClient = new GraphServiceClient(authProvider, okHttpClient);

Expected behavior

I get a GraphServiceClient instance

Actual behavior

java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError[...] Caused by: java.lang.ExceptionInInitializerError at com.microsoft.graph.serviceclient.GraphServiceClient.<init>(GraphServiceClient.java:60) [...] Caused by: java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 11 \{\?[^\}]+} ^ at java.util.regex.Pattern.compileImpl(Native Method) at java.util.regex.Pattern.compile(Pattern.java:1433) at java.util.regex.Pattern.<init>(Pattern.java:1408) at java.util.regex.Pattern.compile(Pattern.java:992) at com.microsoft.kiota.http.OkHttpRequestAdapter.<clinit>(OkHttpRequestAdapter.java:243)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions