Skip to content

Commit

Permalink
fix: Replace deprecated protobuf methods. (#2764)
Browse files Browse the repository at this point in the history
`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()`.
  • Loading branch information
blakeli0 committed May 15, 2024
1 parent 4e31d7d commit 986c090
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1063,12 +1063,10 @@ private static Field parseField(
.setType(TypeParser.parseType(fieldDescriptor))
.setIsMessage(fieldDescriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE)
.setIsEnum(fieldDescriptor.getJavaType() == FieldDescriptor.JavaType.ENUM)
.setIsContainedInOneof(
fieldDescriptor.getContainingOneof() != null
&& !fieldDescriptor.getContainingOneof().isSynthetic())
.setIsContainedInOneof(fieldDescriptor.getRealContainingOneof() != null)
.setIsProto3Optional(
fieldDescriptor.getContainingOneof() != null
&& fieldDescriptor.getContainingOneof().isSynthetic())
&& fieldDescriptor.getRealContainingOneof() == null)
.setIsRepeated(fieldDescriptor.isRepeated())
.setIsRequired(isRequired)
.setFieldInfoFormat(fieldInfoFormat)
Expand Down

0 comments on commit 986c090

Please sign in to comment.