From b9cf19ba5ec4aa6ff108933fa4a1adb075f8c4fb Mon Sep 17 00:00:00 2001 From: zhangskz Date: Thu, 28 Sep 2023 16:39:55 -0400 Subject: [PATCH] Automated rollback of commit 2a55706f9d36afd1742c97fd0d611ea8af0ac3f8. (#14246) * Automated rollback of commit 2a55706f9d36afd1742c97fd0d611ea8af0ac3f8. PiperOrigin-RevId: 569253919 * Remove editions handling not relevant in 24.x --- .../main/java/com/google/protobuf/GeneratedMessageV3.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java index cbad3ca01f000..fe66e86ea2b08 100644 --- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java +++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java @@ -2461,7 +2461,10 @@ public void clear(final GeneratedMessageV3.Builder builder) { final String containingOneofCamelCaseName) { isOneofField = descriptor.getRealContainingOneof() != null; - hasHasMethod = descriptor.hasPresence(); + hasHasMethod = + descriptor.getFile().getSyntax() == FileDescriptor.Syntax.PROTO2 + || descriptor.hasOptionalKeyword() + || (!isOneofField && descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE); ReflectionInvoker reflectionInvoker = new ReflectionInvoker( descriptor,