Skip to content

Commit

Permalink
api: rename connection pool proto messages (#13378)
Browse files Browse the repository at this point in the history
The java_outer_classname must not collide with a type defined within a proto
file in order to compile protos to Java. Additionally, this commit
introduces a format check to prevent this from happening again.

Risk Level: low
Testing: none
Docs Changes:none
Release Notes: none
Fixes #13368

Signed-off-by: Spencer Lewis <[email protected]>
  • Loading branch information
spenceral authored Oct 7, 2020
1 parent 602dfea commit 03f46bb
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package envoy.extensions.upstreams.http.generic.v3;
import "udpa/annotations/status.proto";

option java_package = "io.envoyproxy.envoy.extensions.upstreams.http.generic.v3";
option java_outer_classname = "GenericConnectionPoolProto";
option java_outer_classname = "GenericConnectionPoolProtoOuterClass";
option java_multiple_files = true;
option (udpa.annotations.file_status).package_version_status = ACTIVE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package envoy.extensions.upstreams.http.http.v3;
import "udpa/annotations/status.proto";

option java_package = "io.envoyproxy.envoy.extensions.upstreams.http.http.v3";
option java_outer_classname = "HttpConnectionPoolProto";
option java_outer_classname = "HttpConnectionPoolProtoOuterClass";
option java_multiple_files = true;
option (udpa.annotations.file_status).package_version_status = ACTIVE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package envoy.extensions.upstreams.http.tcp.v3;
import "udpa/annotations/status.proto";

option java_package = "io.envoyproxy.envoy.extensions.upstreams.http.tcp.v3";
option java_outer_classname = "TcpConnectionPoolProto";
option java_outer_classname = "TcpConnectionPoolProtoOuterClass";
option java_multiple_files = true;
option (udpa.annotations.file_status).package_version_status = ACTIVE;

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tools/protoxform/protoprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,16 @@ def CamelCase(s):
file_block = '\n'.join(['syntax = "proto3";\n', package_line])

options = descriptor_pb2.FileOptions()

options.java_outer_classname = CamelCase(os.path.basename(file_proto.name))
for msg in file_proto.message_type:
if msg.name == options.java_outer_classname:
# This is a workaround for Java outer class names that would otherwise
# conflict with types defined within the same proto file, see
# https://github.com/envoyproxy/envoy/pull/13378.
# TODO: in next major version, make this consistent.
options.java_outer_classname += "OuterClass"

options.java_multiple_files = True
options.java_package = 'io.envoyproxy.' + file_proto.package

Expand Down

0 comments on commit 03f46bb

Please sign in to comment.