Skip to content

Commit ebf6798

Browse files
committed
Fix sonar bug
1 parent 1a6f260 commit ebf6798

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

graphql-java-kickstart/src/main/java/graphql/kickstart/execution/GraphQLInvoker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class GraphQLInvoker {
2020

2121
private final GraphQLBuilder graphQLBuilder;
2222
private final BatchedDataLoaderGraphQLBuilder batchedDataLoaderGraphQLBuilder;
23-
private GraphQLInvokerProxy proxy = GraphQL::executeAsync;
23+
private final GraphQLInvokerProxy proxy = GraphQL::executeAsync;
2424

2525
public CompletableFuture<ExecutionResult> executeAsync(
2626
GraphQLSingleInvocationInput invocationInput) {

graphql-java-kickstart/src/main/java/graphql/kickstart/execution/GraphQLInvokerSubjectProxy.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@ public CompletableFuture<ExecutionResult> executeAsync(GraphQL graphQL,
1717
GraphQLContext context = (GraphQLContext) executionInput.getContext();
1818
if (Subject.getSubject(AccessController.getContext()) == null && context.getSubject()
1919
.isPresent()) {
20-
return Subject
21-
.doAs(context.getSubject().get(),
22-
(PrivilegedAction<CompletableFuture<ExecutionResult>>) () -> {
23-
try {
24-
return graphQL.executeAsync(executionInput);
25-
} catch (Exception e) {
26-
throw new RuntimeException(e);
27-
}
28-
});
20+
return context.getSubject()
21+
.map(it -> Subject.doAs(it, doAction(graphQL, executionInput)))
22+
.orElseGet(() -> graphQL.executeAsync(executionInput));
2923
}
3024
return graphQL.executeAsync(executionInput);
3125
}
3226

27+
private PrivilegedAction<CompletableFuture<ExecutionResult>> doAction(GraphQL graphQL,
28+
ExecutionInput executionInput) {
29+
return () -> graphQL.executeAsync(executionInput);
30+
}
31+
3332
}

0 commit comments

Comments
 (0)