Skip to content

Commit

Permalink
Fix descriptor to access type via getType() s.t. messages using delim…
Browse files Browse the repository at this point in the history
…ited encoding are consistently treated as groups for Java lite.

This should fix InvalidWireTypeException in the case of getLiteType() not treating messages with delimited encoding as groups: http://shortn/_2TEPuwIj6P

getJavaType() and needsUtf8Check() changes are no-ops since the type is the same regardless, but these are updated for consistency.

PiperOrigin-RevId: 612972996
  • Loading branch information
zhangskz authored and copybara-github committed Mar 5, 2024
1 parent 730db2d commit 9f001a9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions java/core/src/main/java/com/google/protobuf/Descriptors.java
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ public String getJsonName() {
* FieldDescriptorProto.Type} maps to exactly one Java type.
*/
public JavaType getJavaType() {
return type.getJavaType();
return getType().getJavaType();
}

/** For internal use only. */
Expand Down Expand Up @@ -1298,12 +1298,12 @@ public Type getType() {
/** For internal use only. */
@Override
public WireFormat.FieldType getLiteType() {
return table[type.ordinal()];
return table[getType().ordinal()];
}

/** For internal use only. */
public boolean needsUtf8Check() {
if (type != Type.STRING) {
if (getType() != Type.STRING) {
return false;
}
if (getContainingType().toProto().getOptions().getMapEntry()) {
Expand Down

0 comments on commit 9f001a9

Please sign in to comment.