harshashah23 commented on code in PR #7803: URL: https://github.com/apache/hadoop/pull/7803#discussion_r2220533455
########## hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java: ########## @@ -2975,51 +2990,65 @@ private void processRpcRequest(RpcRequestHeaderProto header, .build(); } - RpcCall call = new RpcCall(this, header.getCallId(), - header.getRetryCount(), rpcRequest, - ProtoUtil.convert(header.getRpcKind()), - header.getClientId().toByteArray(), span, callerContext); - - // Save the priority level assignment by the scheduler - call.setPriorityLevel(callQueue.getPriorityLevel(call)); - call.markCallCoordinated(false); - if(alignmentContext != null && call.rpcRequest != null && - (call.rpcRequest instanceof ProtobufRpcEngine2.RpcProtobufRequest)) { - // if call.rpcRequest is not RpcProtobufRequest, will skip the following - // step and treat the call as uncoordinated. As currently only certain - // ClientProtocol methods request made through RPC protobuf needs to be - // coordinated. - String methodName; - String protoName; - ProtobufRpcEngine2.RpcProtobufRequest req = - (ProtobufRpcEngine2.RpcProtobufRequest) call.rpcRequest; - try { - methodName = req.getRequestHeader().getMethodName(); - protoName = req.getRequestHeader().getDeclaringClassProtocolName(); - if (alignmentContext.isCoordinatedCall(protoName, methodName)) { - call.markCallCoordinated(true); - long stateId; - stateId = alignmentContext.receiveRequestState( - header, getMaxIdleTime()); - call.setClientStateId(stateId); - if (header.hasRouterFederatedState()) { - call.setFederatedNamespaceState(header.getRouterFederatedState()); + // Set AuthorizationContext for this thread if present + byte[] authHeader = null; + boolean authzSet = false; + try { + if (header.hasAuthorizationHeader()) { + authHeader = header.getAuthorizationHeader().toByteArray(); + authzSet = true; + } + + RpcCall call = new RpcCall(this, header.getCallId(), + header.getRetryCount(), rpcRequest, + ProtoUtil.convert(header.getRpcKind()), + header.getClientId().toByteArray(), span, callerContext, authHeader); + + // Save the priority level assignment by the scheduler + call.setPriorityLevel(callQueue.getPriorityLevel(call)); + call.markCallCoordinated(false); + if (alignmentContext != null && call.rpcRequest != null && + (call.rpcRequest instanceof ProtobufRpcEngine2.RpcProtobufRequest)) { + // if call.rpcRequest is not RpcProtobufRequest, will skip the following + // step and treat the call as uncoordinated. As currently only certain + // ClientProtocol methods request made through RPC protobuf needs to be + // coordinated. + String methodName; + String protoName; + ProtobufRpcEngine2.RpcProtobufRequest req = + (ProtobufRpcEngine2.RpcProtobufRequest) call.rpcRequest; + try { + methodName = req.getRequestHeader().getMethodName(); + protoName = req.getRequestHeader().getDeclaringClassProtocolName(); + if (alignmentContext.isCoordinatedCall(protoName, methodName)) { + call.markCallCoordinated(true); + long stateId; + stateId = alignmentContext.receiveRequestState( + header, getMaxIdleTime()); + call.setClientStateId(stateId); + if (header.hasRouterFederatedState()) { + call.setFederatedNamespaceState(header.getRouterFederatedState()); + } } + } catch (IOException ioe) { + throw new RpcServerException("Processing RPC request caught ", ioe); } - } catch (IOException ioe) { - throw new RpcServerException("Processing RPC request caught ", ioe); } - } - try { - internalQueueCall(call); - } catch (RpcServerException rse) { - throw rse; - } catch (IOException ioe) { - throw new FatalRpcServerException( - RpcErrorCodeProto.ERROR_RPC_SERVER, ioe); + try { + internalQueueCall(call); + } catch (RpcServerException rse) { + throw rse; + } catch (IOException ioe) { + throw new FatalRpcServerException( + RpcErrorCodeProto.ERROR_RPC_SERVER, ioe); + } + incRpcCount(); // Increment the rpc count + } finally { + if (authzSet) { + AuthorizationContext.clear(); Review Comment: Do we need authzSet boolean? We can trigger the `AuthorizationContext.clear()` irrespective. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org