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

Handle a null ExecutionResult in GraphqlService #5816

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

ikhoon
Copy link
Contributor

@ikhoon ikhoon commented Jul 18, 2024

Motivation:

If GraphQL.execute(input) returns a CompletableFuture completing exceptionally, NullPointException is raised while handling ExecutionResult.

java.lang.NullPointerException: Cannot invoke "graphql.ExecutionResult.getData()" because "executionResult" is null
	at com.linecorp.armeria.server.graphql.DefaultGraphqlService.lambda$execute$1(DefaultGraphqlService.java:117)
	at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
	at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)

Modifications:

  • Check if cause != null before accessing executionResult in the callback of executeGraphql(ctx, input).

Result:

Motivation:

If `GraphQL.execute(input)` returns a `CompletableFuture` completing
exceptionally, `NullPointException` is raised while handling `ExecutionResult`.
```java
java.lang.NullPointerException: Cannot invoke "graphql.ExecutionResult.getData()" because "executionResult" is null
	at com.linecorp.armeria.server.graphql.DefaultGraphqlService.lambda$execute$1(DefaultGraphqlService.java:117)
	at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
	at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
```

Modifications:

- Check if `cause != null` before accessing `executionResult` in the
  callback of `executeGraphql(ctx, input)`.

Result:

- `NullPointerException` is no longer raised when `GraphqlService` handles errors.
- Closes line#5815
@ikhoon ikhoon added the defect label Jul 18, 2024
@ikhoon ikhoon added this to the 1.30.0 milestone Jul 18, 2024
Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍

@ikhoon ikhoon modified the milestones: 1.30.0, 1.29.3 Jul 19, 2024
@ikhoon ikhoon merged commit 2254fe4 into line:main Jul 19, 2024
15 checks passed
@ikhoon ikhoon deleted the gql-exception-null branch July 19, 2024 05:50
ikhoon added a commit to ikhoon/armeria that referenced this pull request Jul 19, 2024
Motivation:

If `GraphQL.execute(input)` returns a `CompletableFuture` completing
exceptionally, `NullPointException` is raised while handling
`ExecutionResult`.
```java
java.lang.NullPointerException: Cannot invoke "graphql.ExecutionResult.getData()" because "executionResult" is null
	at com.linecorp.armeria.server.graphql.DefaultGraphqlService.lambda$execute$1(DefaultGraphqlService.java:117)
	at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
	at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
```

Modifications:

- Check if `cause != null` before accessing `executionResult` in the
callback of `executeGraphql(ctx, input)`.

Result:

- `NullPointerException` is no longer raised when `GraphqlService`
handles errors.
- Closes line#5815
ikhoon added a commit that referenced this pull request Jul 26, 2024
Motivation:

If `GraphQL.execute(input)` returns a `CompletableFuture` completing
exceptionally, `NullPointException` is raised while handling
`ExecutionResult`.
```java
java.lang.NullPointerException: Cannot invoke "graphql.ExecutionResult.getData()" because "executionResult" is null
	at com.linecorp.armeria.server.graphql.DefaultGraphqlService.lambda$execute$1(DefaultGraphqlService.java:117)
	at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
	at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
```

Modifications:

- Check if `cause != null` before accessing `executionResult` in the
callback of `executeGraphql(ctx, input)`.

Result:

- `NullPointerException` is no longer raised when `GraphqlService`
handles errors.
- Closes #5815
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPE in DefaultGraphqlService
3 participants