diff --git a/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java b/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java index 3d41f3d84e..a794bf0d49 100644 --- a/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java +++ b/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java @@ -65,7 +65,6 @@ public class Parser { private static final String COLON = ":"; private static final String DEFAULT_PORT = "443"; private static final String DOT = "."; - // Allow other parsers to access this. protected static final SourceCodeInfoParser SOURCE_CODE_INFO_PARSER = new SourceCodeInfoParser(); @@ -83,7 +82,9 @@ public static GapicContext parse(CodeGeneratorRequest request) { Optional serviceYamlConfigPathOpt = PluginArgumentParser.parseServiceYamlConfigPath(request); Optional serviceYamlProtoOpt = - ServiceYamlParser.parse(serviceYamlConfigPathOpt.get()); + serviceYamlConfigPathOpt.isPresent() + ? ServiceYamlParser.parse(serviceYamlConfigPathOpt.get()) + : Optional.empty(); // Keep message and resource name parsing separate for cleaner logic. // While this takes an extra pass through the protobufs, the extra time is relatively trivial