From 9f001a965872b1c82e0f61e53aefb92109357213 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Tue, 5 Mar 2024 14:36:14 -0800 Subject: [PATCH] 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 --- .../core/src/main/java/com/google/protobuf/Descriptors.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java/core/src/main/java/com/google/protobuf/Descriptors.java b/java/core/src/main/java/com/google/protobuf/Descriptors.java index a0f1af6b82..6479ea43e3 100644 --- a/java/core/src/main/java/com/google/protobuf/Descriptors.java +++ b/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()) {