diff --git a/java/core/src/main/java/com/google/protobuf/FieldSet.java b/java/core/src/main/java/com/google/protobuf/FieldSet.java index debad4e971bb..c81a1d1fcfd5 100644 --- a/java/core/src/main/java/com/google/protobuf/FieldSet.java +++ b/java/core/src/main/java/com/google/protobuf/FieldSet.java @@ -101,8 +101,15 @@ public void makeImmutable() { int n = fields.getNumArrayEntries(); // Optimisation: hoist out of hot loop. for (int i = 0; i < n; ++i) { Entry entry = fields.getArrayEntryAt(i); - if (entry.getValue() instanceof GeneratedMessageLite) { - ((GeneratedMessageLite) entry.getValue()).makeImmutable(); + Object value = entry.getValue(); + if (value instanceof GeneratedMessageLite) { + ((GeneratedMessageLite) value).makeImmutable(); + } + } + for (Map.Entry entry : fields.getOverflowEntries()) { + Object value = entry.getValue(); + if (value instanceof GeneratedMessageLite) { + ((GeneratedMessageLite) value).makeImmutable(); } } fields.makeImmutable(); diff --git a/java/core/src/test/java/com/google/protobuf/ParserLiteTest.java b/java/core/src/test/java/com/google/protobuf/ParserLiteTest.java index 5433bb4c349e..c903e95246d4 100644 --- a/java/core/src/test/java/com/google/protobuf/ParserLiteTest.java +++ b/java/core/src/test/java/com/google/protobuf/ParserLiteTest.java @@ -76,15 +76,14 @@ public void testParseExtensionsLite() throws Exception { } @Test - public void testParseExtensionsLite_extensionIsMutable() throws Exception { + public void testParseExtensionsLite_extensionIsImmutable() throws Exception { TestAllExtensionsLite message = TestAllExtensionsLite.parseFrom( TestUtilLite.getAllLiteExtensionsSet().toByteArray(), TestUtilLite.getExtensionRegistryLite()); Object nested = message.getExtension(UnittestLite.optionalNestedMessageExtensionLite); if (nested instanceof GeneratedMessageLite) { - // TODO: Make this false. - assertThat(((GeneratedMessageLite) nested).isMutable()).isTrue(); + assertThat(((GeneratedMessageLite) nested).isMutable()).isFalse(); } }