Skip to content

Commit

Permalink
Only intercept call if key is provided in the header
Browse files Browse the repository at this point in the history
  • Loading branch information
abtom committed Mar 22, 2024
1 parent b0bd2a0 commit 2788ba5
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Class which helps set up {@link PeerUids} to be used in tests.
*/
public class PeerUidTestHelper {
public final class PeerUidTestHelper {

/**
* The UID of the calling package is set with the value of this key.
Expand All @@ -31,12 +31,12 @@ public static ServerInterceptor newTestPeerIdentifyingServerInterceptor() {
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
Context context = Context.current();
if (headers.containsKey(UID_KEY)) {
context = context.withValue(PeerUids.REMOTE_PEER, new PeerUid(headers.get(UID_KEY)));
Context context =
Context.current().withValue(PeerUids.REMOTE_PEER, new PeerUid(headers.get(UID_KEY)));
return Contexts.interceptCall(context, call, headers, next);
}

return Contexts.interceptCall(context, call, headers, next);
return next.startCall(call, headers);
}
};
}
Expand Down

0 comments on commit 2788ba5

Please sign in to comment.