@@ -1005,6 +1005,7 @@ public static class Call implements Schedulable,
10051005    final  byte [] clientId ;
10061006    private  final  Span  span ; // the trace span on the server side 
10071007    private  final  CallerContext  callerContext ; // the call context 
1008+     private   final  byte [] authHeader ; // the auth header 
10081009    private  boolean  deferredResponse  = false ;
10091010    private  int  priorityLevel ;
10101011    // the priority level assigned by scheduler, 0 by default 
@@ -1036,6 +1037,11 @@ public Call(int id, int retryCount, Void ignore1, Void ignore2,
10361037
10371038    Call (int  id , int  retryCount , RPC .RpcKind  kind , byte [] clientId ,
10381039        Span  span , CallerContext  callerContext ) {
1040+       this (id , retryCount , kind , clientId , span , callerContext , null );
1041+     }
1042+ 
1043+     Call (int  id , int  retryCount , RPC .RpcKind  kind , byte [] clientId ,
1044+         Span  span , CallerContext  callerContext , byte [] authHeader ) {
10391045      this .callId  = id ;
10401046      this .retryCount  = retryCount ;
10411047      this .timestampNanos  = Time .monotonicNowNanos ();
@@ -1044,6 +1050,7 @@ public Call(int id, int retryCount, Void ignore1, Void ignore2,
10441050      this .clientId  = clientId ;
10451051      this .span  = span ;
10461052      this .callerContext  = callerContext ;
1053+       this .authHeader  = authHeader ;
10471054      this .clientStateId  = Long .MIN_VALUE ;
10481055      this .isCallCoordinated  = false ;
10491056    }
@@ -1244,7 +1251,14 @@ private class RpcCall extends Call {
12441251    RpcCall (Connection  connection , int  id , int  retryCount ,
12451252        Writable  param , RPC .RpcKind  kind , byte [] clientId ,
12461253        Span  span , CallerContext  context ) {
1247-       super (id , retryCount , kind , clientId , span , context );
1254+       this (connection , id , retryCount , param , kind , clientId ,
1255+           span , context , new  byte [0 ]);
1256+     }
1257+ 
1258+     RpcCall (Connection  connection , int  id , int  retryCount ,
1259+         Writable  param , RPC .RpcKind  kind , byte [] clientId ,
1260+         Span  span , CallerContext  context , byte [] authHeader ) {
1261+       super (id , retryCount , kind , clientId , span , context , authHeader );
12481262      this .connection  = connection ;
12491263      this .rpcRequest  = param ;
12501264    }
@@ -2977,17 +2991,18 @@ private void processRpcRequest(RpcRequestHeaderProto header,
29772991      }
29782992
29792993      // Set AuthorizationContext for this thread if present 
2994+       byte [] authHeader  = null ;
29802995      boolean  authzSet  = false ;
29812996      try  {
29822997        if  (header .hasAuthorizationHeader ()) {
2983-           AuthorizationContext . setCurrentAuthorizationHeader ( header .getAuthorizationHeader ().toByteArray () );
2998+           authHeader  =  header .getAuthorizationHeader ().toByteArray ();
29842999          authzSet  = true ;
29853000        }
29863001
29873002        RpcCall  call  = new  RpcCall (this , header .getCallId (),
29883003            header .getRetryCount (), rpcRequest ,
29893004            ProtoUtil .convert (header .getRpcKind ()),
2990-             header .getClientId ().toByteArray (), span , callerContext );
3005+             header .getClientId ().toByteArray (), span , callerContext ,  authHeader );
29913006
29923007        // Save the priority level assignment by the scheduler 
29933008        call .setPriorityLevel (callQueue .getPriorityLevel (call ));
@@ -3259,6 +3274,7 @@ public void run() {
32593274          }
32603275          // always update the current call context 
32613276          CallerContext .setCurrent (call .callerContext );
3277+           AuthorizationContext .setCurrentAuthorizationHeader (call .authHeader );
32623278          UserGroupInformation  remoteUser  = call .getRemoteUser ();
32633279          connDropped  = !call .isOpen ();
32643280          if  (remoteUser  != null ) {
0 commit comments