Clarify exception message for repeated builders.

Technically these methods fail either if the field is primitive (non-message) or if the field is repeated.  However it is confusing to have a repeated message field  claim to be of type 'message' and then fail with an error message that claims you need a message type.

PiperOrigin-RevId: 693789370
pull/19158/head
Protobuf Team Bot 3 weeks ago committed by Copybara-Service
parent 5ebe2e17c7
commit b1882d357b
  1. 17
      csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs
  2. 5
      java/core/src/main/java/com/google/protobuf/GeneratedMessage.java

@ -1,17 +0,0 @@
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#endregion
namespace Google.Protobuf.Reflection;
internal sealed partial class FeatureSetDescriptor
{
// Canonical serialized form of the edition defaults, generated by embed_edition_defaults.
private const string DefaultsBase64 =
"ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH";
}

@ -2709,13 +2709,12 @@ public abstract class GeneratedMessage extends AbstractMessage implements Serial
@Override
public Message.Builder newBuilder() {
throw new UnsupportedOperationException(
"newBuilderForField() called on a non-Message type.");
throw new UnsupportedOperationException("newBuilderForField() called on a repeated field.");
}
@Override
public Message.Builder getBuilder(GeneratedMessage.Builder<?> builder) {
throw new UnsupportedOperationException("getFieldBuilder() called on a non-Message type.");
throw new UnsupportedOperationException("getFieldBuilder() called on a repeated field.");
}
@Override

Loading…
Cancel
Save