Skip to content

Commit 986c090

Browse files
authored
fix: Replace deprecated protobuf methods. (#2764)
`isSynthetic()` is deprecated and will be [removed](protocolbuffers/protobuf@1aeacd4#diff-2228551d02c6661809ca7103db9512eef4c2d01f35556d42316543d92a89edefL2846-L2847) in protobuf-java 4.26.0, replace it so that we can prepare for protobuf-java upgrade. Per [official doc](https://github.com/protocolbuffers/protobuf/blob/main/docs/implementing_proto3_presence.md) of protobuf, an optional field is implemented as a "synthetic" oneof field internally. Also see b/266950618#comment123 for suggested replacements of `isSynthetic()`.
1 parent 4e31d7d commit 986c090

File tree

1 file changed

+2
-4
lines changed
  • gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser

1 file changed

+2
-4
lines changed

gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1063,12 +1063,10 @@ private static Field parseField(
10631063
.setType(TypeParser.parseType(fieldDescriptor))
10641064
.setIsMessage(fieldDescriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE)
10651065
.setIsEnum(fieldDescriptor.getJavaType() == FieldDescriptor.JavaType.ENUM)
1066-
.setIsContainedInOneof(
1067-
fieldDescriptor.getContainingOneof() != null
1068-
&& !fieldDescriptor.getContainingOneof().isSynthetic())
1066+
.setIsContainedInOneof(fieldDescriptor.getRealContainingOneof() != null)
10691067
.setIsProto3Optional(
10701068
fieldDescriptor.getContainingOneof() != null
1071-
&& fieldDescriptor.getContainingOneof().isSynthetic())
1069+
&& fieldDescriptor.getRealContainingOneof() == null)
10721070
.setIsRepeated(fieldDescriptor.isRepeated())
10731071
.setIsRequired(isRequired)
10741072
.setFieldInfoFormat(fieldInfoFormat)

0 commit comments

Comments
 (0)