Skip to content

Possible NullPointerException in BaseRequest when using QueryOption with null value #644

@sebastien-belin-adp

Description

@sebastien-belin-adp

I don't think this is an urgent issue but it happens when I'm using a com.microsoft.graph.options.QueryOption with a null value, which is possible as the constructor clearly allows it:

QueryOption(@Nonnull final String name, @Nullable final Object value)

QueryOption.java L38)

And If I make a request, technically most request as the issue is in com.microsoft.graph.http.BaseRequest I get a NullPointerException as the code is trying to call toString() on a null value:

for (final QueryOption option : queryOptions) {
  uriBuilder.addQueryParameter(option.getName(), option.getValue().toString());
}

BaseRequest.java L191)

Expected behavior

A NullPointerException should not be thrown

Actual behavior

A NullPointerException is thrown

Steps to reproduce the behavior

String username= "some-username";
String id = "some-message-id";
InputStream inputStream = graphClient.users(username).messages(id).content().buildRequest(Collections.singletonList(new QueryOption("name", null))).get();

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions