Skip to content

Commit b3f9dbf

Browse files
committed
Additional cautious finally block
1 parent c26e637 commit b3f9dbf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ 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+
} finally {
99+
SecurityContextHolder.clearContext();
100+
}
97101
}
98102

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

0 commit comments

Comments
 (0)