fix merge conflict

pull/10830/head
Sandy Zhang 2 years ago
commit 308d3b1ef1
  1. 25
      CHANGES.txt
  2. 5
      CMakeLists.txt
  3. 2
      Protobuf-C++.podspec
  4. 2
      Protobuf.podspec
  5. 25
      build_defs/cpp_opts.bzl
  6. 3
      cmake/libprotobuf-lite.cmake
  7. 3
      cmake/libprotobuf.cmake
  8. 1
      cmake/protobuf-config.cmake.in
  9. 14
      cmake/utf8_range.cmake
  10. 3
      conformance/BUILD.bazel
  11. 12
      conformance/conformance.proto
  12. 5
      csharp/.gitignore
  13. 22
      csharp/BUILD.bazel
  14. 2
      csharp/Google.Protobuf.Tools.nuspec
  15. 3
      csharp/generate_protos.sh
  16. 0
      csharp/src/AddressBook/Addressbook.pb.cs
  17. 0
      csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.pb.cs
  18. 0
      csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.pb.cs
  19. 0
      csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.pb.cs
  20. 0
      csharp/src/Google.Protobuf.Test.TestProtos/Unittest.pb.cs
  21. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.pb.cs
  22. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.pb.cs
  23. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.pb.cs
  24. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.pb.cs
  25. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.pb.cs
  26. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936A.pb.cs
  27. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.pb.cs
  28. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.pb.cs
  29. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.pb.cs
  30. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.pb.cs
  31. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.pb.cs
  32. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestSelfreferentialOptions.pb.cs
  33. 0
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.pb.cs
  34. 5
      csharp/src/Google.Protobuf.Test/RefStructCompatibilityTest.cs
  35. 0
      csharp/src/Google.Protobuf/Compiler/Plugin.pb.cs
  36. 2
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  37. 0
      csharp/src/Google.Protobuf/Reflection/Descriptor.pb.cs
  38. 0
      csharp/src/Google.Protobuf/WellKnownTypes/Any.pb.cs
  39. 0
      csharp/src/Google.Protobuf/WellKnownTypes/Api.pb.cs
  40. 0
      csharp/src/Google.Protobuf/WellKnownTypes/Duration.pb.cs
  41. 0
      csharp/src/Google.Protobuf/WellKnownTypes/Empty.pb.cs
  42. 0
      csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.pb.cs
  43. 0
      csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.pb.cs
  44. 0
      csharp/src/Google.Protobuf/WellKnownTypes/Struct.pb.cs
  45. 0
      csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.pb.cs
  46. 0
      csharp/src/Google.Protobuf/WellKnownTypes/Type.pb.cs
  47. 0
      csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.pb.cs
  48. 4
      docs/options.md
  49. 29
      generate_changelog.py
  50. 6
      java/README.md
  51. 2
      java/bom/pom.xml
  52. 3
      java/core/BUILD.bazel
  53. 2
      java/core/generate-test-sources-build.xml
  54. 2
      java/core/pom.xml
  55. 7
      java/core/src/main/java/com/google/protobuf/AbstractMessage.java
  56. 1
      java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java
  57. 13
      java/core/src/main/java/com/google/protobuf/ByteString.java
  58. 14
      java/core/src/main/java/com/google/protobuf/CodedInputStream.java
  59. 1
      java/core/src/main/java/com/google/protobuf/Descriptors.java
  60. 1
      java/core/src/main/java/com/google/protobuf/DynamicMessage.java
  61. 1
      java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java
  62. 1
      java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java
  63. 1
      java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
  64. 2
      java/core/src/main/java/com/google/protobuf/FieldSet.java
  65. 3
      java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
  66. 8
      java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java
  67. 3
      java/core/src/main/java/com/google/protobuf/Internal.java
  68. 4
      java/core/src/main/java/com/google/protobuf/MapField.java
  69. 1
      java/core/src/main/java/com/google/protobuf/Message.java
  70. 1
      java/core/src/main/java/com/google/protobuf/MessageLite.java
  71. 1
      java/core/src/main/java/com/google/protobuf/MessageReflection.java
  72. 3
      java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java
  73. 3
      java/core/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java
  74. 13
      java/core/src/main/java/com/google/protobuf/TextFormat.java
  75. 1
      java/core/src/main/java/com/google/protobuf/TypeRegistry.java
  76. 1
      java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java
  77. 1
      java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java
  78. 1
      java/core/src/test/java/com/google/protobuf/AnyTest.java
  79. 2
      java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java
  80. 3
      java/core/src/test/java/com/google/protobuf/DescriptorsTest.java
  81. 1
      java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java
  82. 1
      java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java
  83. 2
      java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java
  84. 35
      java/core/src/test/java/com/google/protobuf/MapForProto2Test.java
  85. 30
      java/core/src/test/java/com/google/protobuf/MapTest.java
  86. 22
      java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java
  87. 2
      java/core/src/test/java/com/google/protobuf/ParserTest.java
  88. 2
      java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java
  89. 112
      java/core/src/test/java/com/google/protobuf/TextFormatPerformanceTest.java
  90. 4
      java/core/src/test/java/com/google/protobuf/TextFormatTest.java
  91. 1
      java/core/src/test/java/com/google/protobuf/TypeRegistryTest.java
  92. 2
      java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto
  93. 5
      java/core/src/test/proto/com/google/protobuf/nested_builders_test.proto
  94. 56
      java/core/src/test/proto/com/google/protobuf/proto2_text_format_performance_test.proto
  95. 60
      java/core/src/test/proto/com/google/protobuf/proto3_text_format_performance_test.proto
  96. 30
      java/internal/JavaVersionTest.java
  97. 2
      java/kotlin-lite/pom.xml
  98. 9
      java/kotlin-lite/src/main/kotlin/com/google/protobuf/ExtendableMessageLiteExtensions.kt
  99. 16
      java/kotlin-lite/src/test/kotlin/com/google/protobuf/ExtendableMessageLiteExtensionsTest.kt
  100. 2
      java/kotlin/pom.xml
  101. Some files were not shown because too many files have changed in this diff Show More

@ -37,6 +37,12 @@
* Introduce the Printer::{SetRedactDebugString,SetRandomizeDebugString} private flags.
* Introduce global flags to control Printer::{SetRedactDebugString, SetRandomizeDebugString}.
* proto3 string fields no longer trigger clang-tidy warning bugprone-branch-clone.
* Fix the API of DescriptorUpgrader::set_allow_unknown_dependencies to set to True always, and to populate into the DescriptorPool as well.
* Report line numbers consistently in text-format deprecated-field warnings.
* Reserve C++20 keywords
* Fixed C++ code generation for protos that use int32_t, uint32_t, int64_t, uint64_t, size_t as field names.
* Annotate generated C++ public aliases for enum types.
* Change default arena max block size from 8K to 32K.
Kotlin
@ -57,6 +63,13 @@
* Make message-type extensions merge from wire-format instead of building up instances and merging afterwards. This has much better performance.
* Change the Lite runtime to prefer merging from the wireformat into mutable messages rather than building up a new immutable object before merging. This way results in fewer allocations and copy operations.
* Move proto wireformat parsing functionality from the private "parsing constructor" to the Builder class.
* Refactoring java full runtime to reuse sub-message builders and prepare to migrate parsing logic from parse constructor to builder.
* Move proto wireformat parsing functionality from the private "parsing constructor" to the Builder class.
* Change the Lite runtime to prefer merging from the wireformat into mutable messages rather than building up a new immutable object before merging. This way results in fewer allocations and copy operations.
* Make message-type extensions merge from wire-format instead of building up instances and merging afterwards. This has much better performance.
* Fix TextFormat parser to build up recurring (but supposedly not repeated) sub-messages directly from text rather than building a new sub-message and merging the fully formed message into the existing field.
* Fix bug in nested builder caching logic where cleared sub-field builders would remain dirty after a clear and build in a parent layer. https://github.com/protocolbuffers/protobuf/issues/10624
* Performance test for TextFormat to verify fix for https://github.com/protocolbuffers/protobuf/security/advisories/GHSA-h4h5-3hr4-j3g2
Python
* Changes ordering of printed fields in .pyi files from lexicographic to the same ordering found in the proto descriptor.
@ -66,6 +79,18 @@
Compiler
* Print full path name of source .proto file on error
* Include proto message type in the annotation comments.
2022-10-26 version 21.9 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
C++
* Update zlib to 1.2.13 (#10819)
Python
* Target MacOS 10.9 to fix #10799 (#10807)
Ruby
* Replace libc strdup usage with internal impl to restore musl compat (#10818)
2022-10-18 version 21.8 (C++/Java/Python/PHP/Objective-C/C#/Ruby)

@ -23,6 +23,10 @@ endif()
if(POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
# option() honor variables
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif (POLICY CMP0077)
# Project
project(protobuf C CXX)
@ -330,6 +334,7 @@ set_property(CACHE protobuf_ABSL_PROVIDER PROPERTY STRINGS "module" "package")
include(${protobuf_SOURCE_DIR}/cmake/abseil-cpp.cmake)
if (protobuf_BUILD_PROTOBUF_BINARIES)
include(${protobuf_SOURCE_DIR}/cmake/utf8_range.cmake)
include(${protobuf_SOURCE_DIR}/cmake/libprotobuf-lite.cmake)
if (NOT DEFINED protobuf_LIB_PROTOBUF_LITE)
set(protobuf_LIB_PROTOBUF_LITE libprotobuf-lite)

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Protobuf-C++'
s.version = '3.21.8'
s.version = '3.21.9'
s.summary = 'Protocol Buffers v3 runtime library for C++.'
s.homepage = 'https://github.com/google/protobuf'
s.license = 'BSD-3-Clause'

@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
s.version = '3.21.8'
s.version = '3.21.9'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = 'BSD-3-Clause'

@ -2,18 +2,18 @@
COPTS = select({
"//build_defs:config_msvc": [
"/wd4065", # switch statement contains 'default' but no 'case' labels
"/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data
"/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
"/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data
"/wd4305", # 'identifier' : truncation from 'type1' to 'type2'
"/wd4307", # 'operator' : integral constant overflow
"/wd4309", # 'conversion' : truncation of constant value
"/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
"/wd4355", # 'this' : used in base member initializer list
"/wd4506", # no definition for inline function 'function'
"/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning)
"/wd4996", # The compiler encountered a deprecated declaration.
"/wd4065", # switch statement contains 'default' but no 'case' labels
"/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data
"/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
"/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data
"/wd4305", # 'identifier' : truncation from 'type1' to 'type2'
"/wd4307", # 'operator' : integral constant overflow
"/wd4309", # 'conversion' : truncation of constant value
"/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
"/wd4355", # 'this' : used in base member initializer list
"/wd4506", # no definition for inline function 'function'
"/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning)
"/wd4996", # The compiler encountered a deprecated declaration.
],
"//conditions:default": [
"-DHAVE_ZLIB",
@ -22,6 +22,7 @@ COPTS = select({
"-Werror",
],
})
# Android and MSVC builds do not need to link in a separate pthread library.
LINK_OPTS = select({
"//build_defs:config_android": [],

@ -34,3 +34,6 @@ set_target_properties(libprotobuf-lite PROPERTIES
OUTPUT_NAME ${LIB_PREFIX}protobuf-lite
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)
target_include_directories(libprotobuf-lite PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range)
target_link_libraries(libprotobuf-lite PRIVATE utf8_validity)

@ -37,3 +37,6 @@ set_target_properties(libprotobuf PROPERTIES
OUTPUT_NAME ${LIB_PREFIX}protobuf
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotobuf ALIAS libprotobuf)
target_include_directories(libprotobuf PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range)
target_link_libraries(libprotobuf PRIVATE utf8_validity)

@ -4,6 +4,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/protobuf-options.cmake")
# Depend packages
@_protobuf_FIND_ZLIB@
@_protobuf_FIND_ABSL@
@_protobuf_FIND_UTF8_RANGE@
# Imported targets
include("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake")

@ -0,0 +1,14 @@
set(utf8_range_ENABLE_TESTS OFF CACHE BOOL "Disable utf8_range tests")
if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/utf8_range/CMakeLists.txt")
message(FATAL_ERROR
"Cannot find third_party/utf8_range directory that's needed to "
"build conformance tests. If you use git, make sure you have cloned "
"submodules:\n"
" git submodule update --init --recursive\n")
endif()
set(utf8_range_ENABLE_INSTALL ${protobuf_INSTALL} CACHE BOOL "Set install")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range third_party/utf8_range)
set(_protobuf_FIND_UTF8_RANGE "if(NOT TARGET utf8_range)\n find_package(utf8_range CONFIG)\nendif()")

@ -5,7 +5,6 @@ load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_objc_proto_li
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
load(
"@rules_pkg//:mappings.bzl",
"pkg_attributes",
"pkg_filegroup",
"pkg_files",
"strip_prefix",
@ -149,10 +148,10 @@ cc_library(
hdrs = ["binary_json_conformance_suite.h"],
deps = [
":conformance_test",
"@jsoncpp//:jsoncpp",
":test_messages_proto2_proto_cc",
":test_messages_proto3_proto_cc",
"@com_google_absl//absl/status",
"@jsoncpp",
],
)

@ -58,7 +58,7 @@ enum WireFormat {
UNSPECIFIED = 0;
PROTOBUF = 1;
JSON = 2;
JSPB = 3; // Google internal only. Opensource testees just skip it.
JSPB = 3; // Only used inside Google. Opensource testees just skip it.
TEXT_FORMAT = 4;
}
@ -72,8 +72,8 @@ enum TestCategory {
// https://developers.google.com/protocol-buffers/docs/proto3#json_options
// for more detail.
JSON_IGNORE_UNKNOWN_PARSING_TEST = 3;
// Test jspb wire format. Google internal only. Opensource testees just skip
// it.
// Test jspb wire format. Only used inside Google. Opensource testees just
// skip it.
JSPB_TEST = 4;
// Test text format. For cpp, java and python, testees can already deal with
// this type. Testees of other languages can simply skip it.
@ -99,7 +99,7 @@ message ConformanceRequest {
oneof payload {
bytes protobuf_payload = 1;
string json_payload = 2;
// Google internal only. Opensource testees just skip it.
// Only used inside Google. Opensource testees just skip it.
string jspb_payload = 7;
string text_payload = 8;
}
@ -163,8 +163,8 @@ message ConformanceResponse {
string skipped = 5;
// If the input was successfully parsed and the requested output was JSPB,
// serialize to JSPB and set it in this field. JSPB is google internal only
// format. Opensource testees can just skip it.
// serialize to JSPB and set it in this field. JSPB is only used inside
// Google. Opensource testees can just skip it.
string jspb_payload = 7;
// If the input was successfully parsed and the requested output was

5
csharp/.gitignore vendored

@ -33,3 +33,8 @@ lib/protoc.exe
# Benchmark output
BenchmarkDotNet.Artifacts/
# Reinstate generated code for test files
!any_test.pb.*
!map*unittest.pb.*
!unittest*.pb.*

@ -45,17 +45,17 @@ filegroup(
filegroup(
name = "wkt_cs_srcs",
srcs = [
"src/Google.Protobuf/Reflection/Descriptor.cs",
"src/Google.Protobuf/WellKnownTypes/Any.cs",
"src/Google.Protobuf/WellKnownTypes/Api.cs",
"src/Google.Protobuf/WellKnownTypes/Duration.cs",
"src/Google.Protobuf/WellKnownTypes/Empty.cs",
"src/Google.Protobuf/WellKnownTypes/FieldMask.cs",
"src/Google.Protobuf/WellKnownTypes/SourceContext.cs",
"src/Google.Protobuf/WellKnownTypes/Struct.cs",
"src/Google.Protobuf/WellKnownTypes/Timestamp.cs",
"src/Google.Protobuf/WellKnownTypes/Type.cs",
"src/Google.Protobuf/WellKnownTypes/Wrappers.cs",
"src/Google.Protobuf/Reflection/Descriptor.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Any.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Api.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Duration.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Empty.pb.cs",
"src/Google.Protobuf/WellKnownTypes/FieldMask.pb.cs",
"src/Google.Protobuf/WellKnownTypes/SourceContext.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Struct.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Timestamp.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Type.pb.cs",
"src/Google.Protobuf/WellKnownTypes/Wrappers.pb.cs",
],
visibility = ["//src/google/protobuf/compiler/csharp:__pkg__"],
)

@ -5,7 +5,7 @@
<title>Google Protocol Buffers tools</title>
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description>
<version>3.21.8</version>
<version>3.21.9</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/main/LICENSE</licenseUrl>

@ -32,6 +32,7 @@ fi
# descriptor.proto and well-known types
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
--csharp_opt=base_namespace=Google.Protobuf \
--csharp_opt=file_extension=.pb.cs \
src/google/protobuf/descriptor.proto \
src/google/protobuf/any.proto \
src/google/protobuf/api.proto \
@ -52,6 +53,7 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
$PROTOC -Isrc -Icsharp/protos \
--experimental_allow_proto3_optional \
--csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \
--csharp_opt=file_extension=.pb.cs \
--descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \
--include_source_info \
--include_imports \
@ -75,4 +77,5 @@ $PROTOC -Isrc -Icsharp/protos \
# AddressBook sample protos
$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \
--csharp_opt=file_extension=.pb.cs \
examples/addressbook.proto

@ -67,7 +67,10 @@ namespace Google.Protobuf
// We build the code with GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE to avoid the use of ref struct in the generated code.
var compatibilityFlag = "-define:GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE";
var sources = "*.cs"; // the generated sources from the TestProtos project
var args = $"-langversion:3 -target:library {compatibilityFlag} -reference:{testProtosOutputDir}\\Google.Protobuf.dll -out:{testProtosOutputDir}\\TestProtos.RefStructCompatibilityTest.OldCompiler.dll {sources}";
// We suppress CS1691, which flags a warning for the generated line of
// #pragma warning disable 1591, 0612, 3021, 8981
// because CS8981 is unknown to this version of the compiler.
var args = $"-langversion:3 -nologo -nowarn:1691 -target:library {compatibilityFlag} -reference:{testProtosOutputDir}\\Google.Protobuf.dll -out:{testProtosOutputDir}\\TestProtos.RefStructCompatibilityTest.OldCompiler.dll {sources}";
RunOldCsharpCompilerAndCheckSuccess(args, testProtosProjectDir);
}

@ -5,7 +5,7 @@
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
<Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
<VersionPrefix>3.21.8</VersionPrefix>
<VersionPrefix>3.21.9</VersionPrefix>
<LangVersion>10.0</LangVersion>
<Authors>Google Inc.</Authors>
<TargetFrameworks>netstandard1.1;netstandard2.0;net45;net50</TargetFrameworks>

@ -348,3 +348,7 @@ with info about your project (name and website) so we can add an entry for you.
1. Pigweed protobuf compiler
* Website: https://pigweed.dev/pw_protobuf
* Extension: 1155
1. Perfetto
* Website: https://perfetto.dev
* Extension: 1156

@ -1,4 +1,33 @@
#!/usr/bin/env python
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Generates a friendly list of changes per language since the last release."""

@ -23,7 +23,7 @@ If you are using Maven, use the following:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.21.8</version>
<version>3.21.9</version>
</dependency>
```
@ -37,7 +37,7 @@ protobuf-java-util package:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>3.21.8</version>
<version>3.21.9</version>
</dependency>
```
@ -45,7 +45,7 @@ protobuf-java-util package:
If you are using Gradle, add the following to your `build.gradle` file's dependencies:
```
implementation 'com.google.protobuf:protobuf-java:3.21.8'
implementation 'com.google.protobuf:protobuf-java:3.21.9'
```
Again, be sure to check that the version number matches (or is newer than) the version number of protoc that you are using.

@ -4,7 +4,7 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-bom</artifactId>
<version>3.21.8</version>
<version>3.21.9</version>
<packaging>pom</packaging>
<name>Protocol Buffers [BOM]</name>

@ -191,8 +191,8 @@ java_export(
maven_coordinates = "com.google.protobuf:protobuf-java:%s" % PROTOBUF_JAVA_VERSION,
pom_template = "pom_template.xml",
resources = [
"//src/google/protobuf:descriptor_proto_srcs",
"//:well_known_type_protos",
"//src/google/protobuf:descriptor_proto_srcs",
],
tags = ["manual"],
runtime_deps = [":core"],
@ -442,6 +442,7 @@ LITE_TEST_EXCLUSIONS = [
"src/test/java/com/google/protobuf/TestBadIdentifiers.java",
"src/test/java/com/google/protobuf/TextFormatParseInfoTreeTest.java",
"src/test/java/com/google/protobuf/TextFormatParseLocationTest.java",
"src/test/java/com/google/protobuf/TextFormatPerformanceTest.java",
"src/test/java/com/google/protobuf/TextFormatTest.java",
"src/test/java/com/google/protobuf/TestUtil.java",
"src/test/java/com/google/protobuf/TestUtilLite.java",

@ -43,8 +43,10 @@
<arg value="${test.proto.dir}/com/google/protobuf/proto2_message.proto"/>
<arg value="${test.proto.dir}/com/google/protobuf/proto2_message_lite.proto"/>
<arg value="${test.proto.dir}/com/google/protobuf/proto2_unknown_enum_values.proto"/>
<arg value="${test.proto.dir}/com/google/protobuf/proto2_text_format_performance_test.proto"/>
<arg value="${test.proto.dir}/com/google/protobuf/proto3_message.proto"/>
<arg value="${test.proto.dir}/com/google/protobuf/proto3_message_lite.proto"/>
<arg value="${test.proto.dir}/com/google/protobuf/proto3_text_format_performance_test.proto"/>
<arg value="${test.proto.dir}/com/google/protobuf/test_bad_identifiers.proto"/>
<arg value="${test.proto.dir}/com/google/protobuf/test_check_utf8.proto"/>
<arg value="${test.proto.dir}/com/google/protobuf/test_check_utf8_size.proto"/>

@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.21.8</version>
<version>3.21.9</version>
</parent>
<artifactId>protobuf-java</artifactId>

@ -83,7 +83,6 @@ public abstract class AbstractMessage
throw new UnsupportedOperationException("Nested builder is not supported for this type.");
}
@Override
public List<String> findInitializationErrors() {
return MessageReflection.findMissingFields(this);
@ -571,7 +570,7 @@ public abstract class AbstractMessage
protected static int hashLong(long n) {
return (int) (n ^ (n >>> 32));
}
//
/**
* @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
* generated code.
@ -580,7 +579,7 @@ public abstract class AbstractMessage
protected static int hashBoolean(boolean b) {
return b ? 1231 : 1237;
}
//
/**
* @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
* generated code.
@ -589,7 +588,7 @@ public abstract class AbstractMessage
protected static int hashEnum(EnumLite e) {
return e.getNumber();
}
//
/**
* @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
* generated code.

@ -106,7 +106,6 @@ public abstract class AbstractMessageLite<
throw new UnsupportedOperationException();
}
int getSerializedSize(Schema schema) {
int memoizedSerializedSize = getMemoizedSerializedSize();
if (memoizedSerializedSize == -1) {

@ -432,7 +432,10 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
return copyFrom(bytes, 0, bytes.length);
}
/** Wraps the given bytes into a {@code ByteString}. Intended for internal only usage. */
/**
* Wraps the given bytes into a {@code ByteString}. Intended for internal usage within the
* library.
*/
static ByteString wrap(ByteBuffer buffer) {
if (buffer.hasArray()) {
final int offset = buffer.arrayOffset();
@ -443,8 +446,8 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
}
/**
* Wraps the given bytes into a {@code ByteString}. Intended for internal only usage to force a
* classload of ByteString before LiteralByteString.
* Wraps the given bytes into a {@code ByteString}. Intended for internal usage within the library
* to force a classload of ByteString before LiteralByteString.
*/
static ByteString wrap(byte[] bytes) {
// TODO(dweis): Return EMPTY when bytes are empty to reduce allocations?
@ -452,8 +455,8 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
}
/**
* Wraps the given bytes into a {@code ByteString}. Intended for internal only usage to force a
* classload of ByteString before BoundedByteString and LiteralByteString.
* Wraps the given bytes into a {@code ByteString}. Intended for internal usage within the library
* to force a classload of ByteString before BoundedByteString and LiteralByteString.
*/
static ByteString wrap(byte[] bytes, int offset, int length) {
return new BoundedByteString(bytes, offset, length);

@ -254,7 +254,6 @@ public abstract class CodedInputStream {
*/
public abstract void skipMessage(CodedOutputStream output) throws IOException;
// -----------------------------------------------------------------
/** Read a {@code double} field value from the stream. */
@ -300,7 +299,6 @@ public abstract class CodedInputStream {
final ExtensionRegistryLite extensionRegistry)
throws IOException;
/** Read a {@code group} field value from the stream. */
public abstract <T extends MessageLite> T readGroup(
final int fieldNumber, final Parser<T> parser, final ExtensionRegistryLite extensionRegistry)
@ -322,7 +320,6 @@ public abstract class CodedInputStream {
final MessageLite.Builder builder, final ExtensionRegistryLite extensionRegistry)
throws IOException;
/** Read an embedded message field value from the stream. */
public abstract <T extends MessageLite> T readMessage(
final Parser<T> parser, final ExtensionRegistryLite extensionRegistry) throws IOException;
@ -745,7 +742,6 @@ public abstract class CodedInputStream {
}
}
// -----------------------------------------------------------------
@Override
@ -839,7 +835,6 @@ public abstract class CodedInputStream {
--recursionDepth;
}
@Override
public <T extends MessageLite> T readGroup(
final int fieldNumber,
@ -878,7 +873,6 @@ public abstract class CodedInputStream {
popLimit(oldLimit);
}
@Override
public <T extends MessageLite> T readMessage(
final Parser<T> parser, final ExtensionRegistryLite extensionRegistry) throws IOException {
@ -1460,7 +1454,6 @@ public abstract class CodedInputStream {
}
}
// -----------------------------------------------------------------
@Override
@ -1559,7 +1552,6 @@ public abstract class CodedInputStream {
--recursionDepth;
}
@Override
public <T extends MessageLite> T readGroup(
final int fieldNumber,
@ -1598,7 +1590,6 @@ public abstract class CodedInputStream {
popLimit(oldLimit);
}
@Override
public <T extends MessageLite> T readMessage(
final Parser<T> parser, final ExtensionRegistryLite extensionRegistry) throws IOException {
@ -2253,7 +2244,6 @@ public abstract class CodedInputStream {
}
}
// -----------------------------------------------------------------
@Override
@ -2359,7 +2349,6 @@ public abstract class CodedInputStream {
--recursionDepth;
}
@Override
public <T extends MessageLite> T readGroup(
final int fieldNumber,
@ -2398,7 +2387,6 @@ public abstract class CodedInputStream {
popLimit(oldLimit);
}
@Override
public <T extends MessageLite> T readMessage(
final Parser<T> parser, final ExtensionRegistryLite extensionRegistry) throws IOException {
@ -3454,7 +3442,6 @@ public abstract class CodedInputStream {
--recursionDepth;
}
@Override
public <T extends MessageLite> T readGroup(
final int fieldNumber,
@ -3493,7 +3480,6 @@ public abstract class CodedInputStream {
popLimit(oldLimit);
}
@Override
public <T extends MessageLite> T readMessage(
final Parser<T> parser, final ExtensionRegistryLite extensionRegistry) throws IOException {

@ -1728,7 +1728,6 @@ public final class Descriptors {
// down-cast and call mergeFrom directly.
return ((Message.Builder) to).mergeFrom((Message) from);
}
}
// =================================================================

@ -86,7 +86,6 @@ public final class DynamicMessage extends AbstractMessage {
UnknownFieldSet.getDefaultInstance());
}
/** Parse a message of the given type from the given input stream. */
public static DynamicMessage parseFrom(Descriptor type, CodedInputStream input)
throws IOException {

@ -99,7 +99,6 @@ public class ExtensionRegistry extends ExtensionRegistryLite {
return EMPTY_REGISTRY;
}
/** Returns an unmodifiable view of the registry. */
@Override
public ExtensionRegistry getUnmodifiable() {

@ -70,7 +70,6 @@ final class ExtensionRegistryFactory {
return result != null ? result : EMPTY_REGISTRY_LITE;
}
static boolean isFullRegistry(ExtensionRegistryLite registry) {
return EXTENSION_REGISTRY_CLASS != null
&& EXTENSION_REGISTRY_CLASS.isAssignableFrom(registry.getClass());

@ -138,7 +138,6 @@ public class ExtensionRegistryLite {
return result;
}
/** Returns an unmodifiable view of the registry. */
public ExtensionRegistryLite getUnmodifiable() {
return new ExtensionRegistryLite(this);

@ -185,7 +185,6 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
return clone;
}
// =================================================================
/** See {@link Message.Builder#clear()}. */
@ -574,7 +573,6 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
}
}
/** See {@link Message#writeTo(CodedOutputStream)}. */
public void writeTo(final CodedOutputStream output) throws IOException {
for (int i = 0; i < fields.getNumArrayEntries(); i++) {

@ -586,7 +586,6 @@ public abstract class GeneratedMessageLite<
}
}
// =================================================================
// Extensions-related stuff
@ -1250,7 +1249,6 @@ public abstract class GeneratedMessageLite<
return ((Builder) to).mergeFrom((GeneratedMessageLite) from);
}
@Override
public int compareTo(ExtensionDescriptor other) {
return number - other.number;
@ -1291,7 +1289,6 @@ public abstract class GeneratedMessageLite<
}
}
/**
* Lite equivalent to {@link GeneratedMessage.GeneratedExtension}.
*

@ -456,7 +456,6 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
size == 0 ? AbstractProtobufList.DEFAULT_CAPACITY : size * 2);
}
@Override
public void writeTo(final CodedOutputStream output) throws IOException {
MessageReflection.writeMessageTo(this, getAllFieldsRaw(), output, false);
@ -474,7 +473,6 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
return memoizedSize;
}
/**
* This class is used to make a generated protected method inaccessible from user's code (e.g.,
* the {@link #newInstance} method below). When this class is used as a parameter's type in a
@ -520,6 +518,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
});
}
/** Builder class for {@link GeneratedMessageV3}. */
@SuppressWarnings("unchecked")
public abstract static class Builder<BuilderType extends Builder<BuilderType>>
extends AbstractMessage.Builder<BuilderType> {
@ -879,7 +878,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
/**
* Called when a the builder or one of its nested children has changed and any parent should be
* Called when a builder or one of its nested children has changed and any parent should be
* notified of its invalidation.
*/
protected final void onChanged() {
@ -919,6 +918,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
// =================================================================
// Extensions-related stuff
/** Extends {@link MessageOrBuilder} with extension-related functions. */
public interface ExtendableMessageOrBuilder<MessageType extends ExtendableMessage>
extends MessageOrBuilder {
// Re-define for return type covariance.
@ -1169,7 +1169,6 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
return parseUnknownField(input, unknownFields, extensionRegistry, tag);
}
/** Used by parsing constructors in generated classes. */
@Override
protected void makeExtensionsImmutable() {
@ -1847,7 +1846,6 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
FieldDescriptor getDescriptor();
}
// =================================================================
/** Calls Class.getMethod and throws a RuntimeException if it fails. */

@ -375,7 +375,6 @@ public final class Internal {
}
}
/** An empty byte array constant used in generated code. */
public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
@ -386,7 +385,6 @@ public final class Internal {
public static final CodedInputStream EMPTY_CODED_INPUT_STREAM =
CodedInputStream.newInstance(EMPTY_BYTE_ARRAY);
/** Helper method to merge two MessageLite instances. */
static Object mergeMessage(Object destination, Object source) {
return ((MessageLite) destination).toBuilder().mergeFrom((MessageLite) source).buildPartial();
@ -691,5 +689,4 @@ public final class Internal {
@Override
FloatList mutableCopyWithCapacity(int capacity);
}
}

@ -122,7 +122,6 @@ public class MapField<K, V> implements MutabilityOracle {
}
}
private final Converter<K, V> converter;
private MapField(Converter<K, V> converter, StorageMode mode, Map<K, V> mapData) {
@ -137,19 +136,16 @@ public class MapField<K, V> implements MutabilityOracle {
this(new ImmutableMessageConverter<K, V>(defaultEntry), mode, mapData);
}
/** Returns an immutable empty MapField. */
public static <K, V> MapField<K, V> emptyMapField(MapEntry<K, V> defaultEntry) {
return new MapField<K, V>(defaultEntry, StorageMode.MAP, Collections.<K, V>emptyMap());
}
/** Creates a new mutable empty MapField. */
public static <K, V> MapField<K, V> newMapField(MapEntry<K, V> defaultEntry) {
return new MapField<K, V>(defaultEntry, StorageMode.MAP, new LinkedHashMap<K, V>());
}
private Message convertKeyAndValueToMessage(K key, V value) {
return converter.convertKeyAndValueToMessage(key, value);
}

@ -51,7 +51,6 @@ public interface Message extends MessageLite, MessageOrBuilder {
@Override
Parser<? extends Message> getParserForType();
// -----------------------------------------------------------------
// Comparison and hashing

@ -123,7 +123,6 @@ public interface MessageLite extends MessageLiteOrBuilder {
*/
void writeDelimitedTo(OutputStream output) throws IOException;
// =================================================================
// Builders

@ -673,7 +673,6 @@ class MessageReflection {
}
}
static class ExtensionAdapter implements MergeTarget {
private final FieldSet<Descriptors.FieldDescriptor> extensions;

@ -202,6 +202,9 @@ public class SingleFieldBuilder<
builder = null;
}
onChanged();
// After clearing, parent is dirty, but this field builder is now clean and any changes should
// trickle up.
isClean = true;
return this;
}

@ -202,6 +202,9 @@ public class SingleFieldBuilderV3<
builder = null;
}
onChanged();
// After clearing, parent is dirty, but this field builder is now clean and any changes should
// trickle up.
isClean = true;
return this;
}

@ -132,7 +132,7 @@ public final class TextFormat {
public static String shortDebugString(final FieldDescriptor field, final Object value) {
return printer().shortDebugString(field, value);
}
//
/**
* Generates a human readable form of the unknown fields, useful for debugging and other
* purposes, with no newline characters.
@ -191,7 +191,7 @@ public final class TextFormat {
public static String printToUnicodeString(final UnknownFieldSet fields) {
return printer().escapingNonAscii(false).printToString(fields);
}
//
/** @deprecated Use {@code printer().printField(FieldDescriptor, Object, Appendable)} */
@Deprecated
public static void printField(
@ -199,13 +199,13 @@ public final class TextFormat {
throws IOException {
printer().printField(field, value, output);
}
//
/** @deprecated Use {@code printer().printFieldToString(FieldDescriptor, Object)} */
@Deprecated
public static String printFieldToString(final FieldDescriptor field, final Object value) {
return printer().printFieldToString(field, value);
}
//
/**
* Outputs a unicode textual representation of the value of given field value.
*
@ -465,7 +465,6 @@ public final class TextFormat {
@SuppressWarnings({"rawtypes"})
private MapEntry mapEntry;
private final FieldDescriptor.JavaType fieldType;
MapEntryAdapter(Object entry, FieldDescriptor fieldDescriptor) {
@ -1499,7 +1498,6 @@ public final class TextFormat {
PARSER.merge(input, extensionRegistry, builder);
}
/**
* Parse a text-format message from {@code input} and merge the contents into {@code builder}.
* Extensions will be recognized if they are registered in {@code extensionRegistry}.
@ -1530,7 +1528,6 @@ public final class TextFormat {
return output;
}
/**
* Parser for text-format proto2 instances. This class is thread-safe. The implementation largely
* follows google/protobuf/text_format.cc.
@ -1700,7 +1697,6 @@ public final class TextFormat {
merge(toStringBuilder(input), extensionRegistry, builder);
}
private static final int BUFFER_SIZE = 4096;
// TODO(chrisn): See if working around java.io.Reader#read(CharBuffer)
@ -1791,7 +1787,6 @@ public final class TextFormat {
checkUnknownFields(unknownFields);
}
/** Parse a single field from {@code tokenizer} and merge it into {@code builder}. */
private void mergeField(
final Tokenizer tokenizer,

@ -55,7 +55,6 @@ public class TypeRegistry {
return EmptyTypeRegistryHolder.EMPTY;
}
public static Builder newBuilder() {
return new Builder();
}

@ -89,7 +89,6 @@ public final class UnknownFieldSet implements MessageLite {
private static final UnknownFieldSet defaultInstance =
new UnknownFieldSet(new TreeMap<Integer, Field>());
@Override
public boolean equals(Object other) {
if (this == other) {

@ -117,5 +117,4 @@ public final class UnsafeByteOperations {
public static void unsafeWriteTo(ByteString bytes, ByteOutput output) throws IOException {
bytes.writeTo(output);
}
}

@ -58,7 +58,6 @@ public class AnyTest {
TestAllTypes result = container.getValue().unpack(TestAllTypes.class);
TestUtil.assertAllFieldsSet(result);
// Unpacking to a wrong type will throw an exception.
try {
container.getValue().unpack(TestAny.class);

@ -424,7 +424,6 @@ public class CodedInputStreamTest {
}
}
/**
* Test that a bug in skipRawBytes() has been fixed: if the skip skips exactly up to a limit, this
* should not break things.
@ -672,7 +671,6 @@ public class CodedInputStreamTest {
// success.
}
CodedInputStream input = inputType.newDecoder(data100);
input.setRecursionLimit(8);
try {

@ -324,7 +324,6 @@ public class DescriptorsTest {
assertThat(service.getFullName()).isEqualTo("protobuf_unittest.TestService");
assertThat(service.getFile()).isEqualTo(UnittestProto.getDescriptor());
MethodDescriptor fooMethod = service.getMethods().get(0);
assertThat(fooMethod.getName()).isEqualTo("Foo");
assertThat(fooMethod.getInputType()).isEqualTo(UnittestProto.FooRequest.getDescriptor());
@ -337,7 +336,6 @@ public class DescriptorsTest {
assertThat(barMethod.getOutputType()).isEqualTo(UnittestProto.BarResponse.getDescriptor());
assertThat(service.findMethodByName("Bar")).isEqualTo(barMethod);
assertThat(service.findMethodByName("NoSuchMethod")).isNull();
for (int i = 0; i < service.getMethods().size(); i++) {
@ -345,7 +343,6 @@ public class DescriptorsTest {
}
}
@Test
public void testCustomOptions() throws Exception {
// Get the descriptor indirectly from a dependent proto class. This is to

@ -500,5 +500,4 @@ public class FieldPresenceTest {
assertThat(builder.isInitialized()).isTrue();
assertThat(builder.buildPartial().isInitialized()).isTrue();
}
}

@ -801,7 +801,6 @@ public class GeneratedMessageTest {
assertThat(fieldBuilder.build().getField(field)).isEqualTo(expected);
}
@Test
public void testGetBuilderForNonMessageExtensionField() {
TestAllExtensions.Builder builder = TestAllExtensions.newBuilder();

@ -238,7 +238,6 @@ public class LazyFieldLiteTest {
.isEqualTo(messageWithExtensions);
}
// Help methods.
private LazyFieldLite createLazyFieldLiteFromMessage(MessageLite message) {
@ -262,5 +261,4 @@ public class LazyFieldLiteTest {
assertThat(unexpected).isNotSameInstanceAs(actual);
assertThat((unexpected != null && unexpected.equals(actual))).isFalse();
}
}

@ -67,26 +67,26 @@ public class MapForProto2Test {
builder.getMutableInt32ToInt32Field().put(1, 11);
builder.getMutableInt32ToInt32Field().put(2, 22);
builder.getMutableInt32ToInt32Field().put(3, 33);
//
builder.getMutableInt32ToStringField().put(1, "11");
builder.getMutableInt32ToStringField().put(2, "22");
builder.getMutableInt32ToStringField().put(3, "33");
//
builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("11"));
builder.getMutableInt32ToBytesField().put(2, TestUtil.toBytes("22"));
builder.getMutableInt32ToBytesField().put(3, TestUtil.toBytes("33"));
//
builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.FOO);
builder.getMutableInt32ToEnumField().put(2, TestMap.EnumValue.BAR);
builder.getMutableInt32ToEnumField().put(3, TestMap.EnumValue.BAZ);
//
builder.getMutableInt32ToMessageField().put(
1, MessageValue.newBuilder().setValue(11).build());
builder.getMutableInt32ToMessageField().put(
2, MessageValue.newBuilder().setValue(22).build());
builder.getMutableInt32ToMessageField().put(
3, MessageValue.newBuilder().setValue(33).build());
//
builder.getMutableStringToInt32Field().put("1", 11);
builder.getMutableStringToInt32Field().put("2", 22);
builder.getMutableStringToInt32Field().put("3", 33);
@ -175,25 +175,25 @@ public class MapForProto2Test {
builder.getMutableInt32ToInt32Field().put(1, 111);
builder.getMutableInt32ToInt32Field().remove(2);
builder.getMutableInt32ToInt32Field().put(4, 44);
//
builder.getMutableInt32ToStringField().put(1, "111");
builder.getMutableInt32ToStringField().remove(2);
builder.getMutableInt32ToStringField().put(4, "44");
//
builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("111"));
builder.getMutableInt32ToBytesField().remove(2);
builder.getMutableInt32ToBytesField().put(4, TestUtil.toBytes("44"));
//
builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.BAR);
builder.getMutableInt32ToEnumField().remove(2);
builder.getMutableInt32ToEnumField().put(4, TestMap.EnumValue.QUX);
//
builder.getMutableInt32ToMessageField().put(
1, MessageValue.newBuilder().setValue(111).build());
builder.getMutableInt32ToMessageField().remove(2);
builder.getMutableInt32ToMessageField().put(
4, MessageValue.newBuilder().setValue(44).build());
//
builder.getMutableStringToInt32Field().put("1", 111);
builder.getMutableStringToInt32Field().remove("2");
builder.getMutableStringToInt32Field().put("4", 44);
@ -234,7 +234,7 @@ public class MapForProto2Test {
assertMapValuesSet(usingAccessors);
assertThat(usingAccessors).isEqualTo(usingMutableMap);
//
usingMutableMapBuilder = usingMutableMap.toBuilder();
updateMapValuesUsingMutableMap(usingMutableMapBuilder);
usingMutableMap = usingMutableMapBuilder.build();
@ -340,7 +340,7 @@ public class MapForProto2Test {
assertThat(builder.getInt32ToInt32Field()).isEqualTo(newMap(1, 2));
builder.getMutableInt32ToInt32Field().put(2, 3);
assertThat(builder.getInt32ToInt32Field()).isEqualTo(newMap(1, 2, 2, 3));
//
Map<Integer, TestMap.EnumValue> enumMap = builder.getMutableInt32ToEnumField();
enumMap.put(1, TestMap.EnumValue.BAR);
assertThat(builder.build().getInt32ToEnumField())
@ -355,7 +355,7 @@ public class MapForProto2Test {
builder.getMutableInt32ToEnumField().put(2, TestMap.EnumValue.FOO);
assertThat(builder.getInt32ToEnumField())
.isEqualTo(newMap(1, TestMap.EnumValue.BAR, 2, TestMap.EnumValue.FOO));
//
Map<Integer, String> stringMap = builder.getMutableInt32ToStringField();
stringMap.put(1, "1");
assertThat(builder.build().getInt32ToStringField()).isEqualTo(newMap(1, "1"));
@ -368,7 +368,7 @@ public class MapForProto2Test {
assertThat(builder.getInt32ToStringField()).isEqualTo(newMap(1, "1"));
builder.getMutableInt32ToStringField().put(2, "2");
assertThat(builder.getInt32ToStringField()).isEqualTo(newMap(1, "1", 2, "2"));
//
Map<Integer, TestMap.MessageValue> messageMap = builder.getMutableInt32ToMessageField();
messageMap.put(1, TestMap.MessageValue.getDefaultInstance());
assertThat(builder.build().getInt32ToMessageField())
@ -386,7 +386,7 @@ public class MapForProto2Test {
newMap(1, TestMap.MessageValue.getDefaultInstance(),
2, TestMap.MessageValue.getDefaultInstance()));
}
//
@Test
public void testMutableMapLifecycle_collections() {
TestMap.Builder builder = TestMap.newBuilder();
@ -433,13 +433,13 @@ public class MapForProto2Test {
assertThat(builder.getInt32ToInt32Field()).isEqualTo(newMap(1, 2));
assertThat(builder.build().getInt32ToInt32Field()).isEqualTo(newMap(1, 2));
}
//
private static <K, V> Map<K, V> newMap(K key1, V value1) {
Map<K, V> map = new HashMap<K, V>();
map.put(key1, value1);
return map;
}
//
private static <K, V> Map<K, V> newMap(K key1, V value1, K key2, V value2) {
Map<K, V> map = new HashMap<K, V>();
map.put(key1, value1);
@ -635,7 +635,6 @@ public class MapForProto2Test {
// to be different.
}
// The following methods are used to test reflection API.
private static FieldDescriptor f(String name) {

@ -66,26 +66,26 @@ public class MapTest {
builder.getMutableInt32ToInt32Field().put(1, 11);
builder.getMutableInt32ToInt32Field().put(2, 22);
builder.getMutableInt32ToInt32Field().put(3, 33);
//
builder.getMutableInt32ToStringField().put(1, "11");
builder.getMutableInt32ToStringField().put(2, "22");
builder.getMutableInt32ToStringField().put(3, "33");
//
builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("11"));
builder.getMutableInt32ToBytesField().put(2, TestUtil.toBytes("22"));
builder.getMutableInt32ToBytesField().put(3, TestUtil.toBytes("33"));
//
builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.FOO);
builder.getMutableInt32ToEnumField().put(2, TestMap.EnumValue.BAR);
builder.getMutableInt32ToEnumField().put(3, TestMap.EnumValue.BAZ);
//
builder.getMutableInt32ToMessageField().put(
1, MessageValue.newBuilder().setValue(11).build());
builder.getMutableInt32ToMessageField().put(
2, MessageValue.newBuilder().setValue(22).build());
builder.getMutableInt32ToMessageField().put(
3, MessageValue.newBuilder().setValue(33).build());
//
builder.getMutableStringToInt32Field().put("1", 11);
builder.getMutableStringToInt32Field().put("2", 22);
builder.getMutableStringToInt32Field().put("3", 33);
@ -174,25 +174,25 @@ public class MapTest {
builder.getMutableInt32ToInt32Field().put(1, 111);
builder.getMutableInt32ToInt32Field().remove(2);
builder.getMutableInt32ToInt32Field().put(4, 44);
//
builder.getMutableInt32ToStringField().put(1, "111");
builder.getMutableInt32ToStringField().remove(2);
builder.getMutableInt32ToStringField().put(4, "44");
//
builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("111"));
builder.getMutableInt32ToBytesField().remove(2);
builder.getMutableInt32ToBytesField().put(4, TestUtil.toBytes("44"));
//
builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.BAR);
builder.getMutableInt32ToEnumField().remove(2);
builder.getMutableInt32ToEnumField().put(4, TestMap.EnumValue.QUX);
//
builder.getMutableInt32ToMessageField().put(
1, MessageValue.newBuilder().setValue(111).build());
builder.getMutableInt32ToMessageField().remove(2);
builder.getMutableInt32ToMessageField().put(
4, MessageValue.newBuilder().setValue(44).build());
//
builder.getMutableStringToInt32Field().put("1", 111);
builder.getMutableStringToInt32Field().remove("2");
builder.getMutableStringToInt32Field().put("4", 44);
@ -233,7 +233,7 @@ public class MapTest {
assertMapValuesSet(usingAccessors);
assertThat(usingAccessors).isEqualTo(usingMutableMap);
//
usingMutableMapBuilder = usingMutableMap.toBuilder();
updateMapValuesUsingMutableMap(usingMutableMapBuilder);
usingMutableMap = usingMutableMapBuilder.build();
@ -339,7 +339,7 @@ public class MapTest {
assertThat(builder.getInt32ToInt32Field()).isEqualTo(newMap(1, 2));
builder.getMutableInt32ToInt32Field().put(2, 3);
assertThat(builder.getInt32ToInt32Field()).isEqualTo(newMap(1, 2, 2, 3));
//
Map<Integer, TestMap.EnumValue> enumMap = builder.getMutableInt32ToEnumField();
enumMap.put(1, TestMap.EnumValue.BAR);
assertThat(builder.build().getInt32ToEnumField())
@ -354,7 +354,7 @@ public class MapTest {
builder.getMutableInt32ToEnumField().put(2, TestMap.EnumValue.FOO);
assertThat(builder.getInt32ToEnumField()).isEqualTo(
newMap(1, TestMap.EnumValue.BAR, 2, TestMap.EnumValue.FOO));
//
Map<Integer, String> stringMap = builder.getMutableInt32ToStringField();
stringMap.put(1, "1");
assertThat(builder.build().getInt32ToStringField()).isEqualTo(newMap(1, "1"));
@ -367,7 +367,7 @@ public class MapTest {
assertThat(builder.getInt32ToStringField()).isEqualTo(newMap(1, "1"));
builder.putInt32ToStringField(2, "2");
assertThat(builder.getInt32ToStringField()).isEqualTo(newMap(1, "1", 2, "2"));
//
Map<Integer, TestMap.MessageValue> messageMap = builder.getMutableInt32ToMessageField();
messageMap.put(1, TestMap.MessageValue.getDefaultInstance());
assertThat( builder.build().getInt32ToMessageField())
@ -385,7 +385,7 @@ public class MapTest {
newMap(1, TestMap.MessageValue.getDefaultInstance(),
2, TestMap.MessageValue.getDefaultInstance()));
}
//
@Test
public void testMutableMapLifecycle_collections() {
TestMap.Builder builder = TestMap.newBuilder();

@ -33,6 +33,7 @@ package com.google.protobuf;
import static com.google.common.truth.Truth.assertThat;
import protobuf_unittest.Engine;
import protobuf_unittest.TimingBelt;
import protobuf_unittest.Vehicle;
import protobuf_unittest.Wheel;
import java.util.ArrayList;
@ -48,6 +49,27 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class NestedBuildersTest {
@Test
public void test3LayerPropagationWithIntermediateClear() {
Vehicle.Builder vehicleBuilder = Vehicle.newBuilder();
vehicleBuilder.getEngineBuilder().getTimingBeltBuilder();
// This step detaches the TimingBelt.Builder (though it leaves a SingleFieldBuilder in place)
vehicleBuilder.getEngineBuilder().clear();
// These steps build the middle and top level messages, it used to leave the vestigial
// TimingBelt.Builder in a state where further changes didn't propagate anymore
Object unused = vehicleBuilder.getEngineBuilder().build();
unused = vehicleBuilder.build();
TimingBelt expected = TimingBelt.newBuilder().setNumberOfTeeth(124).build();
vehicleBuilder.getEngineBuilder().setTimingBelt(expected);
// Testing that b/254158939 is fixed. It used to be that the setTimingBelt call above didn't
// propagate a change notification and the call below would return a stale version of the timing
// belt.
assertThat(vehicleBuilder.getEngine().getTimingBelt()).isEqualTo(expected);
}
@Test
public void testMessagesAndBuilders() {
Vehicle.Builder vehicleBuilder = Vehicle.newBuilder();

@ -117,7 +117,6 @@ public class ParserTest {
assertRoundTripEquals(TestUtil.getAllSet());
}
@Test
public void testParsePartial() throws Exception {
assertParsePartial(TestRequired.parser(), TestRequired.newBuilder().setA(1).buildPartial());
@ -199,7 +198,6 @@ public class ParserTest {
assertThat(emptyMessage.toByteString()).isEqualTo(TestUtil.getAllSet().toByteString());
}
@Test
public void testOptimizeForSize() throws Exception {
TestOptimizedForSize.Builder builder = TestOptimizedForSize.newBuilder();

@ -99,7 +99,6 @@ public class TestBadIdentifiers extends TestCase {
assertEquals("", message.getFieldName33());
assertEquals(0, message.get2Conflict34());
assertEquals(0, message.get2Conflict35());
}
public void testNumberFields() throws Exception {
@ -120,6 +119,5 @@ public class TestBadIdentifiers extends TestCase {
assertEquals(0, message.get32());
assertEquals(0, message.get64Count());
assertEquals(0, message.get64List().size());
}
}

@ -0,0 +1,112 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.protobuf;
import static com.google.common.truth.Truth.assertThat;
import com.google.protobuf.testing.textformat.performance.proto2.Proto2TextFormatPerformanceProto;
import com.google.protobuf.testing.textformat.performance.proto3.Proto3TextFormatPerformanceProto;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class TextFormatPerformanceTest {
// 10 Seconds is longer than we'd really like, but necesssary to keep this test from being flaky.
// This test is mostly to make sure it doesn't explode to many 10s of seconds for some reason.
private static final long MAX_PARSE_TIME_MS = 10_000L;
private static final int REPEAT_COUNT = 400000;
private static final String CONTAINS_SUB_MESSAGE_WITH_REPEATED_INT32 =
repeat("sub_msg { value: 123 }", REPEAT_COUNT);
private static final String CONTAINS_EXTENSION_SUB_MESSAGE_WITH_REPEATED_INT32 =
repeat(
"[protobuf.testing.textformat.performance.proto2.sub_msg_ext] { value: 123 }",
REPEAT_COUNT);
// OSS Tests are still using JDK 8, which doesn't have JDK 11 String.repeat()
private static String repeat(String text, int count) {
StringBuilder builder = new StringBuilder(text.length() * count);
for (int i = 0; i < count; ++i) {
builder.append(text);
}
return builder.toString();
}
@Test(timeout = MAX_PARSE_TIME_MS)
public void testProto2ImmutableTextFormatParsing() throws Exception {
Proto2TextFormatPerformanceProto.ContainsSubMessageWithRepeatedInt32.Builder builder =
Proto2TextFormatPerformanceProto.ContainsSubMessageWithRepeatedInt32.newBuilder();
TextFormat.merge(CONTAINS_SUB_MESSAGE_WITH_REPEATED_INT32, builder);
Proto2TextFormatPerformanceProto.ContainsSubMessageWithRepeatedInt32 msg = builder.build();
assertThat(msg.getSubMsg().getValueCount()).isEqualTo(REPEAT_COUNT);
for (int i = 0; i < msg.getSubMsg().getValueCount(); ++i) {
assertThat(msg.getSubMsg().getValue(i)).isEqualTo(123);
}
}
@Test(timeout = MAX_PARSE_TIME_MS)
public void testProto2ImmutableExtensionTextFormatParsing() throws Exception {
ExtensionRegistry registry = ExtensionRegistry.newInstance();
Proto2TextFormatPerformanceProto.registerAllExtensions(registry);
Proto2TextFormatPerformanceProto.ContainsExtensionSubMessage.Builder builder =
Proto2TextFormatPerformanceProto.ContainsExtensionSubMessage.newBuilder();
TextFormat.merge(CONTAINS_EXTENSION_SUB_MESSAGE_WITH_REPEATED_INT32, registry, builder);
Proto2TextFormatPerformanceProto.ContainsExtensionSubMessage msg = builder.build();
assertThat(msg.getExtension(Proto2TextFormatPerformanceProto.subMsgExt).getValueCount())
.isEqualTo(REPEAT_COUNT);
for (int i = 0;
i < msg.getExtension(Proto2TextFormatPerformanceProto.subMsgExt).getValueCount();
++i) {
assertThat(msg.getExtension(Proto2TextFormatPerformanceProto.subMsgExt).getValue(i))
.isEqualTo(123);
}
}
@Test(timeout = MAX_PARSE_TIME_MS)
public void testProto3ImmutableTextFormatParsing() throws Exception {
Proto3TextFormatPerformanceProto.ContainsSubMessageWithRepeatedInt32.Builder builder =
Proto3TextFormatPerformanceProto.ContainsSubMessageWithRepeatedInt32.newBuilder();
TextFormat.merge(CONTAINS_SUB_MESSAGE_WITH_REPEATED_INT32, builder);
Proto3TextFormatPerformanceProto.ContainsSubMessageWithRepeatedInt32 msg = builder.build();
assertThat(msg.getSubMsg().getValueCount()).isEqualTo(REPEAT_COUNT);
for (int i = 0; i < msg.getSubMsg().getValueCount(); ++i) {
assertThat(msg.getSubMsg().getValue(i)).isEqualTo(123);
}
}
}

@ -724,7 +724,6 @@ public class TextFormatTest {
assertThat(actual).isEqualTo(expected);
}
@Test
public void testMergeAny_customBuiltTypeRegistry() throws Exception {
TestAny.Builder builder = TestAny.newBuilder();
@ -759,7 +758,6 @@ public class TextFormatTest {
.build());
}
private void assertParseError(String error, String text) {
// Test merge().
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
@ -1399,7 +1397,6 @@ public class TextFormatTest {
.isEqualTo("1: \"\\343\\201\\202\"\n");
}
@Test
public void testParseUnknownExtensions() throws Exception {
TestUtil.TestLogHandler logHandler = new TestUtil.TestLogHandler();
@ -1844,5 +1841,4 @@ public class TextFormatTest {
assertThat(TextFormat.printer().printToString(message))
.isEqualTo("optional_float: -0.0\noptional_double: -0.0\n");
}
}

@ -65,5 +65,4 @@ public final class TypeRegistryTest {
.getDescriptorForTypeUrl("type.googleapis.com/" + descriptor.getFullName()))
.isSameInstanceAs(descriptor);
}
}

@ -30,8 +30,8 @@
syntax = "proto2";
package map_for_proto2_lite_test;
option java_outer_classname = "MapForProto2TestProto";
option optimize_for = LITE_RUNTIME;
option java_package = "map_lite_test";

@ -45,6 +45,11 @@ message Vehicle {
message Engine {
optional int32 cylinder = 1;
optional int32 liters = 2;
optional TimingBelt timing_belt = 3;
}
message TimingBelt {
optional int32 number_of_teeth = 1;
}
message Wheel {

@ -28,51 +28,25 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
syntax = "proto2";
#include "google/protobuf/stubs/strutil.h"
package protobuf.testing.textformat.performance.proto2;
#include <gtest/gtest.h>
#include <locale.h>
option java_package = "com.google.protobuf.testing.textformat.performance.proto2";
option java_outer_classname = "Proto2TextFormatPerformanceProto";
#include "google/protobuf/testing/googletest.h"
#ifdef _WIN32
#define snprintf _snprintf
#endif
namespace google {
namespace protobuf {
namespace {
// TODO(kenton): Copy strutil tests from google3?
TEST(StringUtilityTest, ImmuneToLocales) {
// Remember the old locale.
char* old_locale_cstr = setlocale(LC_NUMERIC, nullptr);
ASSERT_TRUE(old_locale_cstr != nullptr);
std::string old_locale = old_locale_cstr;
// Set the locale to "C".
ASSERT_TRUE(setlocale(LC_NUMERIC, "C") != nullptr);
EXPECT_EQ("1.5", SimpleDtoa(1.5));
EXPECT_EQ("1.5", SimpleFtoa(1.5));
message ContainsSubMessageWithRepeatedInt32 {
optional RepeatedInt32 sub_msg = 1;
}
if (setlocale(LC_NUMERIC, "es_ES") == nullptr &&
setlocale(LC_NUMERIC, "es_ES.utf8") == nullptr) {
// Some systems may not have the desired locale available.
GOOGLE_LOG(WARNING)
<< "Couldn't set locale to es_ES. Skipping this test.";
} else {
EXPECT_EQ("1.5", SimpleDtoa(1.5));
EXPECT_EQ("1.5", SimpleFtoa(1.5));
}
message RepeatedInt32 {
repeated int32 value = 2;
}
// Return to original locale.
setlocale(LC_NUMERIC, old_locale.c_str());
message ContainsExtensionSubMessage {
extensions 1 to max;
}
} // anonymous namespace
} // namespace protobuf
} // namespace google
extend ContainsExtensionSubMessage {
optional RepeatedInt32 sub_msg_ext = 1;
}

@ -1,5 +1,5 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2009 Google Inc. All rights reserved.
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
@ -28,57 +28,17 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: brianolson@google.com (Brian Olson)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
//
// Test program to verify that GzipInputStream is compatible with command line
// gunzip or java.util.zip.GzipInputStream
//
// Reads gzip stream on standard input and writes decompressed data to standard
// output.
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
syntax = "proto3";
#ifdef _WIN32
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#endif
package protobuf.testing.textformat.performance.proto3;
#include "google/protobuf/io/gzip_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"
option java_package = "com.google.protobuf.testing.textformat.performance.proto3";
option java_outer_classname = "Proto3TextFormatPerformanceProto";
using google::protobuf::io::FileInputStream;
using google::protobuf::io::GzipInputStream;
int main(int argc, const char** argv) {
FileInputStream fin(STDIN_FILENO);
GzipInputStream in(&fin);
while (true) {
const void* inptr;
int inlen;
bool ok;
ok = in.Next(&inptr, &inlen);
if (!ok) {
break;
}
if (inlen > 0) {
int err = write(STDOUT_FILENO, inptr, inlen);
if (err != inlen) {
fprintf(stderr, "write unexpectedly returned %d.\n", err);
return 1;
}
}
}
message ContainsSubMessageWithRepeatedInt32 {
optional RepeatedInt32 sub_msg = 1;
}
return 0;
message RepeatedInt32 {
repeated int32 value = 2;
}

@ -1,3 +1,33 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Test that Kokoro is using the expected version of Java.
import static com.google.common.truth.Truth.assertWithMessage;

@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.21.8</version>
<version>3.21.9</version>
</parent>
<artifactId>protobuf-kotlin-lite</artifactId>

@ -37,22 +37,19 @@ import com.google.protobuf.GeneratedMessageLite
operator fun <
M : GeneratedMessageLite.ExtendableMessage<M, *>,
MOrBT : GeneratedMessageLite.ExtendableMessageOrBuilder<M, *>,
T : Any
> MOrBT.get(extension: ExtensionLite<M, T>): T = getExtension(extension)
T : Any> MOrBT.get(extension: ExtensionLite<M, T>): T = getExtension(extension)
/** Sets the current value of the proto extension in this builder. */
operator fun <
M : GeneratedMessageLite.ExtendableMessage<M, B>,
B : GeneratedMessageLite.ExtendableBuilder<M, B>,
T : Any
> B.set(extension: ExtensionLite<M, T>, value: T) {
T : Any> B.set(extension: ExtensionLite<M, T>, value: T) {
setExtension(extension, value)
}
/** Returns true if the specified extension is set. */
operator fun <
M : GeneratedMessageLite.ExtendableMessage<M, *>,
MorBT : GeneratedMessageLite.ExtendableMessageOrBuilder<M, *>
> MorBT.contains(
MorBT : GeneratedMessageLite.ExtendableMessageOrBuilder<M, *>> MorBT.contains(
extension: ExtensionLite<M, *>
): Boolean = hasExtension(extension)

@ -48,31 +48,27 @@ class ExtendableMessageLiteExtensionsTest {
@Test
fun getOnBuilder() {
val builder = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
val builder = ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6)
assertThat(builder[TestProto.int32Extension]).isEqualTo(6)
}
@Test
fun getOnMessage() {
val message = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
.build()
val message =
ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6).build()
assertThat(message[TestProto.int32Extension]).isEqualTo(6)
}
@Test
fun containsPositiveOnMessage() {
val message = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
.build()
val message =
ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6).build()
assertThat(TestProto.int32Extension in message).isTrue()
}
@Test
fun containsPositiveOnBuilder() {
val builder = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
val builder = ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6)
assertThat(TestProto.int32Extension in builder).isTrue()
}

@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.21.8</version>
<version>3.21.9</version>
</parent>
<artifactId>protobuf-kotlin</artifactId>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save