Fix descriptor to access type via getType() s.t. messages using delimited 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
pull/16062/head
Sandy Zhang 11 months ago committed by Copybara-Service
parent 730db2ddde
commit 9f001a9658
  1. 6
      java/core/src/main/java/com/google/protobuf/Descriptors.java

@ -1267,7 +1267,7 @@ public final class Descriptors {
* FieldDescriptorProto.Type} maps to exactly one Java type.
*/
public JavaType getJavaType() {
return type.getJavaType();
return getType().getJavaType();
}
/** For internal use only. */
@ -1298,12 +1298,12 @@ public final class Descriptors {
/** 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()) {

Loading…
Cancel
Save