Skip to content

Commit 84d45e8

Browse files
committed
Additional cautious finally block
1 parent c26e637 commit 84d45e8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

spring-grpc-core/src/main/java/org/springframework/grpc/server/security/AuthenticationProcessInterceptor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ else if (user == null || !user.isAuthenticated()) {
9393
}
9494

9595
SecurityContext currentContext = SecurityContextHolder.getContext();
96-
return new SecurityContextClearingListener<>(next.startCall(call, headers), currentContext);
96+
try {
97+
return new SecurityContextClearingListener<>(next.startCall(call, headers), currentContext);
98+
}
99+
finally {
100+
SecurityContextHolder.clearContext();
101+
}
97102
}
98103

99104
static class SecurityContextClearingListener<ReqT> extends SimpleForwardingServerCallListener<ReqT> {

0 commit comments

Comments
 (0)