@@ -604,57 +604,55 @@ private void createStream(CreateStreamCommand command, ChannelPromise promise)
604604 }
605605
606606 CharSequence authorityHeader = command .headers ().authority ();
607- if (authorityHeader != null ) {
608- // No need to verify authority for the rpc outgoing header if it is same as the authority
609- // for the transport
610- if (!authority .contentEquals (authorityHeader )) {
611- Status authorityVerificationStatus = peerVerificationResults .get (
612- authorityHeader .toString ());
613- if (authorityVerificationStatus == null ) {
614- if (attributes .get (GrpcAttributes .ATTR_AUTHORITY_VERIFIER ) != null ) {
615- authorityVerificationStatus = attributes .get (GrpcAttributes .ATTR_AUTHORITY_VERIFIER )
616- .verifyAuthority (authorityHeader .toString ());
617- peerVerificationResults .put (authorityHeader .toString (), authorityVerificationStatus );
618- if (!authorityVerificationStatus .isOk () && !enablePerRpcAuthorityCheck ) {
619- logger .log (Level .WARNING , String .format ("%s.%s" ,
620- authorityVerificationStatus .getDescription (),
621- enablePerRpcAuthorityCheck
622- ? "" : " This will be an error in the future." ),
623- InternalStatus .asRuntimeExceptionWithoutStacktrace (
624- authorityVerificationStatus , null ));
625- }
626- } else {
627- authorityVerificationStatus = Status .UNAVAILABLE .withDescription (
628- "Authority verifier not found to verify authority" );
629- command .stream ().setNonExistent ();
630- command .stream ().transportReportStatus (
631- authorityVerificationStatus , RpcProgress .PROCESSED , true , new Metadata ());
632- promise .setFailure (InternalStatus .asRuntimeExceptionWithoutStacktrace (
633- authorityVerificationStatus , null ));
634- return ;
635- }
636- }
637- if (authorityVerificationStatus != null && !authorityVerificationStatus .isOk ()) {
638- if (enablePerRpcAuthorityCheck ) {
639- command .stream ().setNonExistent ();
640- command .stream ().transportReportStatus (
641- authorityVerificationStatus , RpcProgress .PROCESSED , true , new Metadata ());
642- promise .setFailure (InternalStatus .asRuntimeExceptionWithoutStacktrace (
643- authorityVerificationStatus , null ));
644- return ;
645- }
646- }
647- }
648- } else {
607+ if (authorityHeader == null ) {
649608 Status authorityVerificationStatus = Status .UNAVAILABLE .withDescription (
650609 "Missing authority header" );
651610 command .stream ().setNonExistent ();
652611 command .stream ().transportReportStatus (
653- Status .UNAVAILABLE , RpcProgress .DROPPED , true , new Metadata ());
612+ Status .UNAVAILABLE , RpcProgress .PROCESSED , true , new Metadata ());
654613 promise .setFailure (InternalStatus .asRuntimeExceptionWithoutStacktrace (
655614 authorityVerificationStatus , null ));
656615 return ;
657616 }
617+ // No need to verify authority for the rpc outgoing header if it is same as the authority
618+ // for the transport
619+ if (!authority .contentEquals (authorityHeader )) {
620+ Status authorityVerificationStatus = peerVerificationResults .get (
621+ authorityHeader .toString ());
622+ if (authorityVerificationStatus == null ) {
623+ if (attributes .get (GrpcAttributes .ATTR_AUTHORITY_VERIFIER ) == null ) {
624+ authorityVerificationStatus = Status .UNAVAILABLE .withDescription (
625+ "Authority verifier not found to verify authority" );
626+ command .stream ().setNonExistent ();
627+ command .stream ().transportReportStatus (
628+ authorityVerificationStatus , RpcProgress .PROCESSED , true , new Metadata ());
629+ promise .setFailure (InternalStatus .asRuntimeExceptionWithoutStacktrace (
630+ authorityVerificationStatus , null ));
631+ return ;
632+ }
633+ authorityVerificationStatus = attributes .get (GrpcAttributes .ATTR_AUTHORITY_VERIFIER )
634+ .verifyAuthority (authorityHeader .toString ());
635+ peerVerificationResults .put (authorityHeader .toString (), authorityVerificationStatus );
636+ if (!authorityVerificationStatus .isOk () && !enablePerRpcAuthorityCheck ) {
637+ logger .log (Level .WARNING , String .format ("%s.%s" ,
638+ authorityVerificationStatus .getDescription (),
639+ enablePerRpcAuthorityCheck
640+ ? "" : " This will be an error in the future." ),
641+ InternalStatus .asRuntimeExceptionWithoutStacktrace (
642+ authorityVerificationStatus , null ));
643+ }
644+ }
645+ if (!authorityVerificationStatus .isOk ()) {
646+ if (enablePerRpcAuthorityCheck ) {
647+ command .stream ().setNonExistent ();
648+ command .stream ().transportReportStatus (
649+ authorityVerificationStatus , RpcProgress .PROCESSED , true , new Metadata ());
650+ promise .setFailure (InternalStatus .asRuntimeExceptionWithoutStacktrace (
651+ authorityVerificationStatus , null ));
652+ return ;
653+ }
654+ }
655+ }
658656 // Get the stream ID for the new stream.
659657 int streamId ;
660658 try {
0 commit comments