PROTOBUF_SYNC_PIPER
pull/10233/head
theodorerose 3 years ago
parent 4f593b7482
commit 6cf86ac37a
  1. 5
      java/core/src/main/java/com/google/protobuf/Internal.java
  2. 4
      java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java
  3. 4
      java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java
  4. 3
      java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java
  5. 3
      java/core/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java
  6. 2
      java/core/src/test/java/com/google/protobuf/SingleFieldBuilderV3Test.java
  7. 2
      java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java
  8. 1
      java/core/src/test/java/com/google/protobuf/TextFormatTest.java
  9. 2
      src/google/protobuf/compiler/cpp/message.cc
  10. 5
      src/google/protobuf/util/json_format_proto3.proto
  11. 18
      src/google/protobuf/util/json_util_test.cc

@ -600,6 +600,7 @@ public final class Internal {
void addInt(int element);
/** Like {@link #set(int, Object)} but more efficient in that it doesn't box the element. */
@CanIgnoreReturnValue
int setInt(int index, int element);
/** Returns a mutable clone of this list with the specified capacity. */
@ -620,6 +621,7 @@ public final class Internal {
void addBoolean(boolean element);
/** Like {@link #set(int, Object)} but more efficient in that it doesn't box the element. */
@CanIgnoreReturnValue
boolean setBoolean(int index, boolean element);
/** Returns a mutable clone of this list with the specified capacity. */
@ -640,6 +642,7 @@ public final class Internal {
void addLong(long element);
/** Like {@link #set(int, Object)} but more efficient in that it doesn't box the element. */
@CanIgnoreReturnValue
long setLong(int index, long element);
/** Returns a mutable clone of this list with the specified capacity. */
@ -660,6 +663,7 @@ public final class Internal {
void addDouble(double element);
/** Like {@link #set(int, Object)} but more efficient in that it doesn't box the element. */
@CanIgnoreReturnValue
double setDouble(int index, double element);
/** Returns a mutable clone of this list with the specified capacity. */
@ -680,6 +684,7 @@ public final class Internal {
void addFloat(float element);
/** Like {@link #set(int, Object)} but more efficient in that it doesn't box the element. */
@CanIgnoreReturnValue
float setFloat(int index, float element);
/** Returns a mutable clone of this list with the specified capacity. */

@ -277,6 +277,7 @@ public class RepeatedFieldBuilder<
* @param message the message to set
* @return the builder
*/
@CanIgnoreReturnValue
public RepeatedFieldBuilder<MType, BType, IType> setMessage(int index, MType message) {
checkNotNull(message);
ensureMutableMessageList();
@ -298,6 +299,7 @@ public class RepeatedFieldBuilder<
* @param message the message to add
* @return the builder
*/
@CanIgnoreReturnValue
public RepeatedFieldBuilder<MType, BType, IType> addMessage(MType message) {
checkNotNull(message);
ensureMutableMessageList();
@ -319,6 +321,7 @@ public class RepeatedFieldBuilder<
* @param message the message to add
* @return the builder
*/
@CanIgnoreReturnValue
public RepeatedFieldBuilder<MType, BType, IType> addMessage(int index, MType message) {
checkNotNull(message);
ensureMutableMessageList();
@ -338,6 +341,7 @@ public class RepeatedFieldBuilder<
* @param values the messages to add
* @return the builder
*/
@CanIgnoreReturnValue
public RepeatedFieldBuilder<MType, BType, IType> addAllMessages(
Iterable<? extends MType> values) {
for (final MType value : values) {

@ -277,6 +277,7 @@ public class RepeatedFieldBuilderV3<
* @param message the message to set
* @return the builder
*/
@CanIgnoreReturnValue
public RepeatedFieldBuilderV3<MType, BType, IType> setMessage(int index, MType message) {
checkNotNull(message);
ensureMutableMessageList();
@ -298,6 +299,7 @@ public class RepeatedFieldBuilderV3<
* @param message the message to add
* @return the builder
*/
@CanIgnoreReturnValue
public RepeatedFieldBuilderV3<MType, BType, IType> addMessage(MType message) {
checkNotNull(message);
ensureMutableMessageList();
@ -319,6 +321,7 @@ public class RepeatedFieldBuilderV3<
* @param message the message to add
* @return the builder
*/
@CanIgnoreReturnValue
public RepeatedFieldBuilderV3<MType, BType, IType> addMessage(int index, MType message) {
checkNotNull(message);
ensureMutableMessageList();
@ -338,6 +341,7 @@ public class RepeatedFieldBuilderV3<
* @param values the messages to add
* @return the builder
*/
@CanIgnoreReturnValue
public RepeatedFieldBuilderV3<MType, BType, IType> addAllMessages(
Iterable<? extends MType> values) {
for (final MType value : values) {

@ -156,6 +156,7 @@ public class SingleFieldBuilder<
* @param message the message to set
* @return the builder
*/
@CanIgnoreReturnValue
public SingleFieldBuilder<MType, BType, IType> setMessage(MType message) {
this.message = checkNotNull(message);
if (builder != null) {
@ -172,6 +173,7 @@ public class SingleFieldBuilder<
* @param value the value to merge from
* @return the builder
*/
@CanIgnoreReturnValue
public SingleFieldBuilder<MType, BType, IType> mergeFrom(MType value) {
if (builder == null && message == message.getDefaultInstanceForType()) {
message = value;
@ -188,6 +190,7 @@ public class SingleFieldBuilder<
* @return the builder
*/
@SuppressWarnings("unchecked")
@CanIgnoreReturnValue
public SingleFieldBuilder<MType, BType, IType> clear() {
message =
(MType)

@ -156,6 +156,7 @@ public class SingleFieldBuilderV3<
* @param message the message to set
* @return the builder
*/
@CanIgnoreReturnValue
public SingleFieldBuilderV3<MType, BType, IType> setMessage(MType message) {
this.message = checkNotNull(message);
if (builder != null) {
@ -172,6 +173,7 @@ public class SingleFieldBuilderV3<
* @param value the value to merge from
* @return the builder
*/
@CanIgnoreReturnValue
public SingleFieldBuilderV3<MType, BType, IType> mergeFrom(MType value) {
if (builder == null && message == message.getDefaultInstanceForType()) {
message = value;
@ -188,6 +190,7 @@ public class SingleFieldBuilderV3<
* @return the builder
*/
@SuppressWarnings("unchecked")
@CanIgnoreReturnValue
public SingleFieldBuilderV3<MType, BType, IType> clear() {
message =
(MType)

@ -82,7 +82,7 @@ public class SingleFieldBuilderV3Test {
assertThat(mockParent.getInvalidationCount()).isEqualTo(0);
assertThat(builder.getBuilder().getOptionalInt32()).isEqualTo(1);
assertThat(builder.getMessage().getOptionalInt32()).isEqualTo(1);
builder.build();
TestAllTypes unused = builder.build();
builder.getBuilder().setOptionalInt32(2);
assertThat(builder.getBuilder().getOptionalInt32()).isEqualTo(2);
assertThat(builder.getMessage().getOptionalInt32()).isEqualTo(2);

@ -49,7 +49,7 @@ public class TestBadIdentifiers extends TestCase {
TestBadIdentifiersProto.Override.getDefaultInstance();
}
@SuppressWarnings("IgnoredPureGetter") // TODO(b/221602772): Fix this
@SuppressWarnings({"IgnoredPureGetter", "CheckReturnValue"}) // TODO(b/221602772): Fix this
public void testGetDescriptor() {
TestBadIdentifiersProto.getDescriptor();
TestBadIdentifiersProto.Descriptor.getDefaultInstance().getDescriptor();

@ -823,6 +823,7 @@ public class TextFormatTest {
}
}
@CanIgnoreReturnValue
private TestAllTypes assertParseSuccessWithOverwriteForbidden(String text)
throws TextFormat.ParseException {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();

@ -3052,7 +3052,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
GOOGLE_CHECK(!first_split_chunk_processed || chunk_is_split);
if (chunk_is_split && !first_split_chunk_processed) {
// Some fields are cleared without checking has_bit. So we add the
// condidtion here to avoid writing to the default split instance.
// condition here to avoid writing to the default split instance.
format("if (!IsSplitMessageDefault()) {\n");
format.Indent();
first_split_chunk_processed = true;

@ -180,6 +180,11 @@ message TestBoolValue {
map<bool, int32> bool_map = 2;
}
message TestNullValue {
google.protobuf.NullValue null_value = 20;
repeated google.protobuf.NullValue repeated_null_value = 21;
}
message TestCustomJsonName {
int32 value = 1 [json_name = "@value"];
}

@ -973,6 +973,24 @@ TEST_P(JsonTest, TestFieldMask) {
EXPECT_EQ(m2->value().paths(0), "yep.really");
}
TEST_P(JsonTest, TestLegalNullsInArray) {
auto m = ToProto<proto3::TestNullValue>(R"json({
"repeatedNullValue": [null]
})json");
ASSERT_OK(m);
EXPECT_EQ(m->repeated_null_value_size(), 1);
EXPECT_EQ(m->repeated_null_value(0), google::protobuf::NULL_VALUE);
auto m2 = ToProto<proto3::TestValue>(R"json({
"repeatedValue": [null]
})json");
ASSERT_OK(m2);
EXPECT_EQ(m2->repeated_value_size(), 1);
EXPECT_TRUE(m2->repeated_value(0).has_null_value());
}
TEST_P(JsonTest, DISABLED_HtmlEscape) {
TestMessage m;
m.set_string_value("</script>");

Loading…
Cancel
Save