@@ -643,24 +643,26 @@ static LongrunningOperation parseLro(
643643 // These can be short names (e.g. FooMessage) or fully-qualified names with the *proto* package.
644644 String responseTypeName = lroInfo .getResponseType ();
645645 String metadataTypeName = lroInfo .getMetadataType ();
646- String [] responseTypeNameComponents = responseTypeName .split ("\\ ." );
647- String [] metadataTypeNameComponents = metadataTypeName .split ("\\ ." );
646+
647+ int lastDotIndex = responseTypeName .lastIndexOf ('.' );
648+ boolean isResponseTypeNameShortOnly = lastDotIndex < 0 ;
648649 String responseTypeShortName =
649- responseTypeNameComponents [responseTypeNameComponents .length - 1 ];
650- String metadataTypeShortName =
651- metadataTypeNameComponents [metadataTypeNameComponents .length - 1 ];
650+ lastDotIndex >= 0 ? responseTypeName .substring (lastDotIndex + 1 ) : responseTypeName ;
652651
653- // True if the LRO-specified name is the short name.
654- boolean isResponseTypeNameShortOnly = responseTypeName .equals (responseTypeShortName );
655- boolean isMetadataTypeNameShortOnly = metadataTypeName .equals (metadataTypeShortName );
652+ lastDotIndex = metadataTypeName .lastIndexOf ('.' );
653+ boolean isMetadataTypeNameShortOnly = lastDotIndex < 0 ;
654+ String metadataTypeShortName =
655+ lastDotIndex >= 0 ? metadataTypeName .substring (lastDotIndex + 1 ) : metadataTypeName ;
656656
657657 Message responseMessage = null ;
658658 Message metadataMessage = null ;
659659
660660 // The messageTypes map keys to the Java fully-qualified name.
661661 for (Map .Entry <String , Message > messageEntry : messageTypes .entrySet ()) {
662- String [] packageComponents = messageEntry .getKey ().split ("\\ ." );
663- String messageShortName = packageComponents [packageComponents .length - 1 ];
662+ String messageKey = messageEntry .getKey ();
663+ int messageLastDotIndex = messageEntry .getKey ().lastIndexOf ('.' );
664+ String messageShortName =
665+ messageLastDotIndex >= 0 ? messageKey .substring (messageLastDotIndex + 1 ) : messageKey ;
664666 if (responseMessage == null ) {
665667 if (isResponseTypeNameShortOnly && responseTypeName .equals (messageShortName )) {
666668 responseMessage = messageEntry .getValue ();
0 commit comments