diff --git a/protoc-gen-java-optional-test/src/test/resources/no-package-type.proto b/protoc-gen-java-optional-test/src/test/resources/no-package-type.proto new file mode 100644 index 0000000..1e1959d --- /dev/null +++ b/protoc-gen-java-optional-test/src/test/resources/no-package-type.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "org.test.datatypes"; + +message NoPackageTestMessage { + message NestedTestMessage { + string string = 1; + optional string optional_string = 2; + } +} + diff --git a/protoc-gen-java-optional/src/main/java/org/grpcmock/protoc/plugin/OptionalGenerator.java b/protoc-gen-java-optional/src/main/java/org/grpcmock/protoc/plugin/OptionalGenerator.java index 3446c23..664123f 100644 --- a/protoc-gen-java-optional/src/main/java/org/grpcmock/protoc/plugin/OptionalGenerator.java +++ b/protoc-gen-java-optional/src/main/java/org/grpcmock/protoc/plugin/OptionalGenerator.java @@ -104,7 +104,7 @@ private Stream handleMessage( String javaPackage ) { String filePath = javaPackage.replace(".", DIR_SEPARATOR) + DIR_SEPARATOR + fileName + JAVA_EXTENSION; - String fullMethodName = protoPackage + "." + messageDescriptor.getName(); + String fullMethodName = (protoPackage.isEmpty() ? "" : (protoPackage + ".")) + messageDescriptor.getName(); return Stream.concat( handleSingleMessage(messageDescriptor, filePath, fullMethodName),