From ee05cc11db9dca7a97e53f27ec206d4edad0ab62 Mon Sep 17 00:00:00 2001 From: s1341 Date: Thu, 11 Feb 2021 10:38:48 +0200 Subject: [PATCH 01/55] Fix missing -llog when compiling for android --- configure.ac | 13 +++++++++++++ src/Makefile.am | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index eb70a76e16..5188e305d1 100644 --- a/configure.ac +++ b/configure.ac @@ -223,6 +223,19 @@ case "$target_os" in esac AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1]) +AC_MSG_CHECKING(whether -llog is needed) +ANDROID_TEST=no +case "$target_os" in + *android*) + ANDROID_TEST=yes + ;; +esac +AC_MSG_RESULT($ANDROID_TEST) +if test "x$ANDROID_TEST" = xyes; then + LIBLOG_LIBS="-llog" +fi +AC_SUBST([LIBLOG_LIBS]) + # HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS, # since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock # too. diff --git a/src/Makefile.am b/src/Makefile.am index 5940ce187e..503ed2ec54 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,7 +30,7 @@ endif AM_CXXFLAGS = $(NO_OPT_CXXFLAGS) $(PROTOBUF_OPT_FLAG) -AM_LDFLAGS = $(PTHREAD_CFLAGS) +AM_LDFLAGS = $(PTHREAD_CFLAGS) ${LIBLOG_LIBS} # If I say "dist_include_DATA", automake complains that $(includedir) is not # a "legitimate" directory for DATA. Screw you, automake. From 0894247c2197f0924af1a0a61c195b8423022f41 Mon Sep 17 00:00:00 2001 From: "David L. Jones" Date: Thu, 11 Feb 2021 16:15:30 -0800 Subject: [PATCH 02/55] Add autotools to release languages. --- .github/mergeable.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/mergeable.yml b/.github/mergeable.yml index 8577f086ee..4027cf5a9f 100644 --- a/.github/mergeable.yml +++ b/.github/mergeable.yml @@ -11,8 +11,8 @@ mergeable: regex: 'release notes: yes' message: 'Please include release notes: yes' - must_include: - regex: '^(c#|c\+\+|cleanup|conformance tests|integration|java|javascript|go|objective-c|php|python|ruby|bazel|cmake|protoc)' - message: 'Please include at least a language label (e.g., c++, java, python). Or apply one of the following labels: bazel, cmake, cleanup, conformance tests, integration, protoc.' + regex: '^(autotools|bazel|c#|c\+\+|cleanup|cmake|conformance tests|integration|go|java|javascript|objective-c|php|protoc|python|ruby)' + message: 'Please include at least a language label (e.g., c++, java, python). Or apply one of the following labels: autotools, bazel, cmake, cleanup, conformance tests, integration, protoc.' - must_include: regex: 'release notes: no' message: 'Please include release notes: no' From 947e2e189a9948fee8a624a7ff12802dc3d12e28 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Fri, 19 Feb 2021 21:36:09 +0000 Subject: [PATCH 03/55] deps: update JUnit and Truth --- java/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/pom.xml b/java/pom.xml index 79850b17d3..592a251b6a 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -75,7 +75,7 @@ junit junit - 4.13.1 + 4.13.2 test @@ -104,7 +104,7 @@ com.google.truth truth - 1.0.1 + 1.1.2 test From 9879f423ff9f2af8e85ce2f64ef7dc5fe6779c28 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 24 Feb 2021 16:41:35 -0800 Subject: [PATCH 04/55] Ruby <2.7now uses WeakMap too, which prevents memory leaks. Ruby <2.7 does not allow non-finalizable objects to be WeakMap keys: https://bugs.ruby-lang.org/issues/16035 We work around this by using a secondary map for Ruby <2.7 which maps the non-finalizable integer to a distinct object. For now we accept that the entries in the secondary map wil never be collected. If this becomes a problem we can perform a GC pass every so often that looks at the contents of the object cache to decide what can be deleted from the secondary map. --- ruby/ext/google/protobuf_c/defs.c | 2 +- ruby/ext/google/protobuf_c/map.c | 11 +- ruby/ext/google/protobuf_c/message.c | 8 +- ruby/ext/google/protobuf_c/protobuf.c | 172 +++++++++----------- ruby/ext/google/protobuf_c/protobuf.h | 17 +- ruby/ext/google/protobuf_c/repeated_field.c | 11 +- 6 files changed, 103 insertions(+), 118 deletions(-) diff --git a/ruby/ext/google/protobuf_c/defs.c b/ruby/ext/google/protobuf_c/defs.c index 10ded86118..1d912c1a2e 100644 --- a/ruby/ext/google/protobuf_c/defs.c +++ b/ruby/ext/google/protobuf_c/defs.c @@ -295,7 +295,7 @@ static VALUE DescriptorPool_alloc(VALUE klass) { self->def_to_descriptor = rb_hash_new(); self->symtab = upb_symtab_new(); - ObjectCache_Add(self->symtab, ret, _upb_symtab_arena(self->symtab)); + ObjectCache_Add(self->symtab, ret); return ret; } diff --git a/ruby/ext/google/protobuf_c/map.c b/ruby/ext/google/protobuf_c/map.c index 9d7d16b529..9d0b37e10f 100644 --- a/ruby/ext/google/protobuf_c/map.c +++ b/ruby/ext/google/protobuf_c/map.c @@ -93,7 +93,7 @@ VALUE Map_GetRubyWrapper(upb_map* map, upb_fieldtype_t key_type, if (val == Qnil) { val = Map_alloc(cMap); Map* self; - ObjectCache_Add(map, val, Arena_get(arena)); + ObjectCache_Add(map, val); TypedData_Get_Struct(val, Map, &Map_type, self); self->map = map; self->arena = arena; @@ -318,7 +318,7 @@ static VALUE Map_init(int argc, VALUE* argv, VALUE _self) { self->map = upb_map_new(Arena_get(self->arena), self->key_type, self->value_type_info.type); - ObjectCache_Add(self->map, _self, Arena_get(self->arena)); + ObjectCache_Add(self->map, _self); if (init_arg != Qnil) { Map_merge_into_self(_self, init_arg); @@ -590,9 +590,10 @@ VALUE Map_eq(VALUE _self, VALUE _other) { */ static VALUE Map_freeze(VALUE _self) { Map* self = ruby_to_Map(_self); - - ObjectCache_Pin(self->map, _self, Arena_get(self->arena)); - RB_OBJ_FREEZE(_self); + if (!RB_OBJ_FROZEN(_self)) { + Arena_Pin(self->arena, _self); + RB_OBJ_FREEZE(_self); + } return _self; } diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c index 77b0e8b9c1..67f22212c6 100644 --- a/ruby/ext/google/protobuf_c/message.c +++ b/ruby/ext/google/protobuf_c/message.c @@ -105,7 +105,7 @@ void Message_InitPtr(VALUE self_, upb_msg *msg, VALUE arena) { Message* self = ruby_to_Message(self_); self->msg = msg; self->arena = arena; - ObjectCache_Add(msg, self_, Arena_get(arena)); + ObjectCache_Add(msg, self_); } VALUE Message_GetArena(VALUE msg_rb) { @@ -855,8 +855,10 @@ static VALUE Message_to_h(VALUE _self) { */ static VALUE Message_freeze(VALUE _self) { Message* self = ruby_to_Message(_self); - ObjectCache_Pin(self->msg, _self, Arena_get(self->arena)); - RB_OBJ_FREEZE(_self); + if (!RB_OBJ_FROZEN(_self)) { + Arena_Pin(self->arena, _self); + RB_OBJ_FREEZE(_self); + } return _self; } diff --git a/ruby/ext/google/protobuf_c/protobuf.c b/ruby/ext/google/protobuf_c/protobuf.c index 737cd284b8..c27f30aa2d 100644 --- a/ruby/ext/google/protobuf_c/protobuf.c +++ b/ruby/ext/google/protobuf_c/protobuf.c @@ -167,30 +167,55 @@ void StringBuilder_PrintMsgval(StringBuilder* b, upb_msgval val, // Arena // ----------------------------------------------------------------------------- -void Arena_free(void* data) { upb_arena_free(data); } +typedef struct { + upb_arena *arena; + VALUE pinned_objs; +} Arena; + +static void Arena_mark(void *data) { + Arena *arena = data; + rb_gc_mark(arena->pinned_objs); +} + +static void Arena_free(void *data) { + Arena *arena = data; + upb_arena_free(arena->arena); +} static VALUE cArena; const rb_data_type_t Arena_type = { "Google::Protobuf::Internal::Arena", - { NULL, Arena_free, NULL }, + { Arena_mark, Arena_free, NULL }, + .flags = RUBY_TYPED_FREE_IMMEDIATELY, }; static VALUE Arena_alloc(VALUE klass) { - upb_arena *arena = upb_arena_new(); + Arena *arena = ALLOC(Arena); + arena->arena = upb_arena_new(); + arena->pinned_objs = Qnil; return TypedData_Wrap_Struct(klass, &Arena_type, arena); } upb_arena *Arena_get(VALUE _arena) { - upb_arena *arena; - TypedData_Get_Struct(_arena, upb_arena, &Arena_type, arena); - return arena; + Arena *arena; + TypedData_Get_Struct(_arena, Arena, &Arena_type, arena); + return arena->arena; } VALUE Arena_new() { return Arena_alloc(cArena); } +void Arena_Pin(VALUE _arena, VALUE obj) { + Arena *arena; + TypedData_Get_Struct(_arena, Arena, &Arena_type, arena); + if (arena->pinned_objs == Qnil) { + arena->pinned_objs = rb_ary_new(); + } + rb_ary_push(arena->pinned_objs, obj); +} + void Arena_register(VALUE module) { VALUE internal = rb_define_module_under(module, "Internal"); VALUE klass = rb_define_class_under(internal, "Arena", rb_cObject); @@ -209,122 +234,79 @@ void Arena_register(VALUE module) { // different wrapper objects for the same C object, which saves memory and // preserves object identity. // -// We use Hash and/or WeakMap for the cache. WeakMap is faster overall -// (probably due to removal being integrated with GC) but doesn't work for Ruby -// <2.7 (see note below). We need Hash for Ruby <2.7 and for cases where we -// need to GC-root the object (notably when the object has been frozen). +// We use WeakMap for the cache. For Ruby <2.7 we also need a secondary Hash +// to store WeakMap keys because Ruby <2.7 WeakMap doesn't allow non-finalizable +// keys. #if RUBY_API_VERSION_CODE >= 20700 -#define USE_WEAK_MAP 1 +#define USE_SECONDARY_MAP 0 #else -#define USE_WEAK_MAP 0 +#define USE_SECONDARY_MAP 1 #endif -static VALUE ObjectCache_GetKey(const void* key) { - char buf[sizeof(key)]; - memcpy(&buf, &key, sizeof(key)); - intptr_t key_int = (intptr_t)key; - PBRUBY_ASSERT((key_int & 3) == 0); - return LL2NUM(key_int >> 2); -} +#if USE_SECONDARY_MAP -// Strong object cache, uses regular Hash and GC-roots objects. -// - For Ruby <2.7, used for all objects. -// - For Ruby >=2.7, used only for frozen objects, so we preserve the "frozen" -// bit (since this information is not preserved at the upb level). +// Maps Numeric -> Object. The object is then used as a key into the WeakMap. +// This is needed for Ruby <2.7 where a number cannot be a key to WeakMap. +// The object is used only for its identity; it does not contain any data. +VALUE secondary_map = Qnil; -VALUE strong_obj_cache = Qnil; - -static void StrongObjectCache_Init() { - rb_gc_register_address(&strong_obj_cache); - strong_obj_cache = rb_hash_new(); +static void SecondaryMap_Init() { + rb_gc_register_address(&secondary_map); + secondary_map = rb_hash_new(); } -static void StrongObjectCache_Remove(void* key) { - VALUE key_rb = ObjectCache_GetKey(key); - PBRUBY_ASSERT(rb_hash_lookup(strong_obj_cache, key_rb) != Qnil); - rb_hash_delete(strong_obj_cache, key_rb); +static VALUE SecondaryMap_Get(VALUE key) { + VALUE ret = rb_hash_lookup(secondary_map, key); + if (ret == Qnil) { + ret = rb_eval_string("Object.new"); + rb_hash_aset(secondary_map, key, ret); + } + return ret; } -static VALUE StrongObjectCache_Get(const void* key) { - VALUE key_rb = ObjectCache_GetKey(key); - return rb_hash_lookup(strong_obj_cache, key_rb); -} +#endif -static void StrongObjectCache_Add(const void* key, VALUE val, - upb_arena* arena) { - PBRUBY_ASSERT(StrongObjectCache_Get(key) == Qnil); - VALUE key_rb = ObjectCache_GetKey(key); - rb_hash_aset(strong_obj_cache, key_rb, val); - upb_arena_addcleanup(arena, (void*)key, StrongObjectCache_Remove); +static VALUE ObjectCache_GetKey(const void* key) { + char buf[sizeof(key)]; + memcpy(&buf, &key, sizeof(key)); + intptr_t key_int = (intptr_t)key; + PBRUBY_ASSERT((key_int & 3) == 0); + VALUE ret = LL2NUM(key_int >> 2); +#if USE_SECONDARY_MAP + ret = SecondaryMap_Get(ret); +#endif + return ret; } -// Weak object cache. This speeds up the test suite significantly, so we -// presume it speeds up real code also. However we can only use it in Ruby -// >=2.7 due to: -// https://bugs.ruby-lang.org/issues/16035 - -#if USE_WEAK_MAP +// Public ObjectCache API. VALUE weak_obj_cache = Qnil; +ID item_get; +ID item_set; -static void WeakObjectCache_Init() { +static void ObjectCache_Init() { rb_gc_register_address(&weak_obj_cache); VALUE klass = rb_eval_string("ObjectSpace::WeakMap"); weak_obj_cache = rb_class_new_instance(0, NULL, klass); -} - -static VALUE WeakObjectCache_Get(const void* key) { - VALUE key_rb = ObjectCache_GetKey(key); - VALUE ret = rb_funcall(weak_obj_cache, rb_intern("[]"), 1, key_rb); - return ret; -} - -static void WeakObjectCache_Add(const void* key, VALUE val) { - PBRUBY_ASSERT(WeakObjectCache_Get(key) == Qnil); - VALUE key_rb = ObjectCache_GetKey(key); - rb_funcall(weak_obj_cache, rb_intern("[]="), 2, key_rb, val); - PBRUBY_ASSERT(WeakObjectCache_Get(key) == val); -} - -#endif - -// Public ObjectCache API. - -static void ObjectCache_Init() { - StrongObjectCache_Init(); -#if USE_WEAK_MAP - WeakObjectCache_Init(); + item_get = rb_intern("[]"); + item_set = rb_intern("[]="); +#if USE_SECONDARY_MAP + SecondaryMap_Init(); #endif } -void ObjectCache_Add(const void* key, VALUE val, upb_arena *arena) { -#if USE_WEAK_MAP - (void)arena; - WeakObjectCache_Add(key, val); -#else - StrongObjectCache_Add(key, val, arena); -#endif +void ObjectCache_Add(const void* key, VALUE val) { + PBRUBY_ASSERT(ObjectCache_Get(key) == Qnil); + VALUE key_rb = ObjectCache_GetKey(key); + rb_funcall(weak_obj_cache, item_set, 2, key_rb, val); + PBRUBY_ASSERT(ObjectCache_Get(key) == val); } // Returns the cached object for this key, if any. Otherwise returns Qnil. VALUE ObjectCache_Get(const void* key) { -#if USE_WEAK_MAP - return WeakObjectCache_Get(key); -#else - return StrongObjectCache_Get(key); -#endif -} - -void ObjectCache_Pin(const void* key, VALUE val, upb_arena *arena) { -#if USE_WEAK_MAP - PBRUBY_ASSERT(WeakObjectCache_Get(key) == val); - // This will GC-root the object, but we'll still use the weak map for - // actual lookup. - StrongObjectCache_Add(key, val, arena); -#else - // Value is already pinned, nothing to do. -#endif + VALUE key_rb = ObjectCache_GetKey(key); + return rb_funcall(weak_obj_cache, item_get, 1, key_rb); } /* diff --git a/ruby/ext/google/protobuf_c/protobuf.h b/ruby/ext/google/protobuf_c/protobuf.h index 90fb0a2093..e4873b34d2 100644 --- a/ruby/ext/google/protobuf_c/protobuf.h +++ b/ruby/ext/google/protobuf_c/protobuf.h @@ -55,6 +55,13 @@ const upb_fielddef* map_field_value(const upb_fielddef* field); VALUE Arena_new(); upb_arena *Arena_get(VALUE arena); +// Pins this Ruby object to the lifetime of this arena, so that as long as the +// arena is alive this object will not be collected. +// +// We use this to guarantee that the "frozen" bit on the object will be +// remembered, even if the user drops their reference to this precise object. +void Arena_Pin(VALUE arena, VALUE obj); + // ----------------------------------------------------------------------------- // ObjectCache // ----------------------------------------------------------------------------- @@ -68,19 +75,11 @@ upb_arena *Arena_get(VALUE arena); // Adds an entry to the cache. The "arena" parameter must give the arena that // "key" was allocated from. In Ruby <2.7.0, it will be used to remove the key // from the cache when the arena is destroyed. -void ObjectCache_Add(const void* key, VALUE val, upb_arena *arena); +void ObjectCache_Add(const void* key, VALUE val); // Returns the cached object for this key, if any. Otherwise returns Qnil. VALUE ObjectCache_Get(const void* key); -// Pins the previously added object so it is GC-rooted. This turns the -// reference to "val" from weak to strong. We use this to guarantee that the -// "frozen" bit on the object will be remembered, even if the user drops their -// reference to this precise object. -// -// The "arena" parameter must give the arena that "key" was allocated from. -void ObjectCache_Pin(const void* key, VALUE val, upb_arena *arena); - // ----------------------------------------------------------------------------- // StringBuilder, for inspect // ----------------------------------------------------------------------------- diff --git a/ruby/ext/google/protobuf_c/repeated_field.c b/ruby/ext/google/protobuf_c/repeated_field.c index 65ca3c6647..da3e7ef0cd 100644 --- a/ruby/ext/google/protobuf_c/repeated_field.c +++ b/ruby/ext/google/protobuf_c/repeated_field.c @@ -88,7 +88,7 @@ VALUE RepeatedField_GetRubyWrapper(upb_array* array, TypeInfo type_info, if (val == Qnil) { val = RepeatedField_alloc(cRepeatedField); RepeatedField* self; - ObjectCache_Add(array, val, Arena_get(arena)); + ObjectCache_Add(array, val); TypedData_Get_Struct(val, RepeatedField, &RepeatedField_type, self); self->array = array; self->arena = arena; @@ -500,9 +500,10 @@ VALUE RepeatedField_eq(VALUE _self, VALUE _other) { */ static VALUE RepeatedField_freeze(VALUE _self) { RepeatedField* self = ruby_to_RepeatedField(_self); - - ObjectCache_Pin(self->array, _self, Arena_get(self->arena)); - RB_OBJ_FREEZE(_self); + if (!RB_OBJ_FROZEN(_self)) { + Arena_Pin(self->arena, _self); + RB_OBJ_FREEZE(_self); + } return _self; } @@ -610,7 +611,7 @@ VALUE RepeatedField_init(int argc, VALUE* argv, VALUE _self) { self->type_info = TypeInfo_FromClass(argc, argv, 0, &self->type_class, &ary); self->array = upb_array_new(arena, self->type_info.type); - ObjectCache_Add(self->array, _self, arena); + ObjectCache_Add(self->array, _self); if (ary != Qnil) { if (!RB_TYPE_P(ary, T_ARRAY)) { From eb542e606b55de33df41d3868c909c73d040110b Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Thu, 25 Feb 2021 09:15:27 -0800 Subject: [PATCH 05/55] Updated CHANGES.txt for 3.15.3 release --- CHANGES.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 47cacd92cb..d73ef274c5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +2021-02-25 version 3.15.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + Ruby + * Ruby <2.7 now uses WeakMap too, which prevents memory leaks. (#8341) + 2021-02-23 version 3.15.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) Ruby From 983d115bd9f388468fd65d1e623b858eb12bc528 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Wed, 24 Feb 2021 16:54:55 -0800 Subject: [PATCH 06/55] Update protobuf version --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 23 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- src/Makefile.am | 2 +- src/google/protobuf/any.pb.h | 2 +- src/google/protobuf/api.pb.h | 2 +- src/google/protobuf/compiler/plugin.pb.h | 2 +- src/google/protobuf/descriptor.pb.h | 2 +- src/google/protobuf/duration.pb.h | 2 +- src/google/protobuf/empty.pb.h | 2 +- src/google/protobuf/field_mask.pb.h | 2 +- src/google/protobuf/port_def.inc | 2 +- src/google/protobuf/source_context.pb.h | 2 +- src/google/protobuf/struct.pb.h | 2 +- src/google/protobuf/stubs/common.h | 2 +- src/google/protobuf/timestamp.pb.h | 2 +- src/google/protobuf/type.pb.h | 2 +- src/google/protobuf/wrappers.pb.h | 2 +- 31 files changed, 49 insertions(+), 34 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index 4b54404dae..1f35b0a146 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Protobuf-C++' - s.version = '3.15.2' + s.version = '3.15.3' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = '3-Clause BSD License' diff --git a/Protobuf.podspec b/Protobuf.podspec index a2f415e82a..b2958e0283 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -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.15.2' + s.version = '3.15.3' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/configure.ac b/configure.ac index 232dd87126..2eb58902dd 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # In the SVN trunk, the version should always be the next anticipated release # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.15.2],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.15.3],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 34a381d676..60c7fecda9 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.15.2 + 3.15.3 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 57aa48744b..3b2542ccc0 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.15.2 + 3.15.3 7.2 Google Inc. diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 197cf14c43..cec091173e 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.15.2 + 3.15.3 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index 9b6a617910..4fc530b9db 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.2 + 3.15.3 protobuf-java diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 5d307c4b0a..478ba0e15c 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.2 + 3.15.3 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index 0fa99235a6..2a69b95fe4 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.2 + 3.15.3 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 778d5ea390..9028b1b2f0 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.2 + 3.15.3 protobuf-java-util diff --git a/js/package.json b/js/package.json index 4610c05028..b5d23ebcb8 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.15.2", + "version": "3.15.3", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index c6990c92e1..75a440cd55 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ protobuf-opensource@google.com yes - 2021-02-23 - + 2021-02-24 + - 3.15.2 - 3.15.2 + 3.15.3 + 3.15.3 stable @@ -835,5 +835,20 @@ G A release. + + + 3.15.3 + 3.15.3 + + + stable + stable + + 2021-02-24 + + 3-Clause BSD License + + + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 9919f4ab1e..a03261c295 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -76,7 +76,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -#define PHP_PROTOBUF_VERSION "3.15.2" +#define PHP_PROTOBUF_VERSION "3.15.3" // ptr -> PHP object cache. This is a weak map that caches lazily-created // wrapper objects around upb types: diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 3dc469cbb5..591ab09284 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.15.2 + 3.15.3 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 4807f97b0c..04a5ff6cdb 100644 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,4 +30,4 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.15.2' +__version__ = '3.15.3' diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 6896a23ecb..dde0c30183 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.15.2" + s.version = "3.15.3" git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" diff --git a/src/Makefile.am b/src/Makefile.am index 36584771a6..442b2f11e2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 26:2:0 +PROTOBUF_VERSION = 26:3:0 if GCC # Turn on all warnings except for sign comparison (we ignore sign comparison diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index beef6476f4..70fcad5d02 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index aa202b4ea9..d3068c94c8 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 8edc7aa465..f802d16b49 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index cce46c3775..b0faa4a3db 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 341fd804b0..32f30c080e 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 49de6ea0b0..c7079dd36e 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 12d39ab121..736920bc2e 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index ae9fef425a..2299d55a60 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -335,7 +335,7 @@ // Shared google3/opensource definitions. ////////////////////////////////////// -#define PROTOBUF_VERSION 3015002 +#define PROTOBUF_VERSION 3015003 #define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3015000 #define PROTOBUF_MIN_PROTOC_VERSION 3015000 #define PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index e64b0a0dee..9539dc5872 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index f3f01df905..9613809e93 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 8c8fb87337..b920b7ff9b 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -82,7 +82,7 @@ namespace internal { // The current version, represented as a single integer to make comparison // easier: major * 10^6 + minor * 10^3 + micro -#define GOOGLE_PROTOBUF_VERSION 3015002 +#define GOOGLE_PROTOBUF_VERSION 3015003 // A suffix string for alpha, beta or rc releases. Empty for stable releases. #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index f2802bbe77..c16d82ce8e 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 84698bd5f8..88918c7339 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 1c91f7da04..e71d733f69 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. From d6f0c9b18727809ca6fe2bf22a34fe2a4786e6c8 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 26 Feb 2021 10:45:41 -0800 Subject: [PATCH 07/55] Updated changelog. --- CHANGES.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index d73ef274c5..14b9b3a7ae 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,18 @@ +Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + C++ + * Allow MessageDifferencer::TreatAsSet() (and friends) to override previous + calls instead of crashing. + * Reduce the size of generated proto headers for protos with `string` or + `bytes` fields. + * Move arena() operation on uncommon path to out-of-line routine + * For iterator-pair function parameter types, take both iterators by value. + * Code-space savings and perhaps some modest performance improvements in + RepeatedPtrField. + + Java: + * Exceptions thrown while reading from an InputStream in parseFrom are now included as causes. + 2021-02-25 version 3.15.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) Ruby From f645c7ed07d2d82c8b2356245957d681cd7adbd2 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 26 Feb 2021 10:54:13 -0800 Subject: [PATCH 08/55] Fixed spelling errors surfaced by CodeSpell. --- .../com/google/protobuf/InvalidProtocolBufferException.java | 2 +- src/google/protobuf/compiler/cpp/cpp_file.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java b/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java index b47eeefe28..4b4303374c 100644 --- a/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java +++ b/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java @@ -78,7 +78,7 @@ public class InvalidProtocolBufferException extends IOException { /* This write can be racy if the same exception is stored and then thrown by multiple custom * InputStreams on different threads. But since it only ever moves from false->true, there's no * problem. A thread checking this condition after catching this exception from a delegate - * stram of CodedInputStream is guaranteed to always observe true, because a write on the same + * stream of CodedInputStream is guaranteed to always observe true, because a write on the same * thread set the value when the exception left the delegate. A thread checking the same * condition with an exception created by CodedInputStream is guaranteed to always see false, * because the exception has not been exposed to any code that could publish it to other threads diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index d47a0d6fee..9a0c7ab651 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -856,8 +856,8 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { "};\n" // This function exists to be marked as weak. // It can significantly speed up compilation by breaking up LLVM's SCC in - // the .pb.cc tranlation units. Large translation units see a reduction of - // more than 35% of walltime for optimized builds. + // the .pb.cc translation units. Large translation units see a reduction + // of more than 35% of walltime for optimized builds. // Without the weak attribute all the messages in the file, including all // the vtables and everything they use become part of the same SCC through // a cycle like: From e9091e6d8c0adaa83bcb260aa47c316024f1c97a Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Mon, 1 Mar 2021 23:59:39 +0300 Subject: [PATCH 09/55] Fix some constness / char literal issues being found by MSVC standard conforming mode (#8344) * Fix some constness / char literal issues being found by MSVC standard conforming mode * Switch to const_cast from C-style casts --- python/google/protobuf/pyext/descriptor_pool.cc | 4 ++-- python/google/protobuf/pyext/map_container.cc | 8 ++++---- python/google/protobuf/pyext/message.cc | 10 +++++----- python/google/protobuf/pyext/message.h | 2 +- python/google/protobuf/pyext/message_factory.cc | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/python/google/protobuf/pyext/descriptor_pool.cc b/python/google/protobuf/pyext/descriptor_pool.cc index 6f1464e321..a24d45d834 100644 --- a/python/google/protobuf/pyext/descriptor_pool.cc +++ b/python/google/protobuf/pyext/descriptor_pool.cc @@ -176,9 +176,9 @@ static PyDescriptorPool* PyDescriptorPool_NewWithDatabase( // The public DescriptorPool constructor. static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) { - static char* kwlist[] = {"descriptor_db", 0}; + static const char* kwlist[] = {"descriptor_db", 0}; PyObject* py_database = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist, &py_database)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", const_cast(kwlist), &py_database)) { return NULL; } DescriptorDatabase* database = NULL; diff --git a/python/google/protobuf/pyext/map_container.cc b/python/google/protobuf/pyext/map_container.cc index a0ee16fe86..711c30472c 100644 --- a/python/google/protobuf/pyext/map_container.cc +++ b/python/google/protobuf/pyext/map_container.cc @@ -462,10 +462,10 @@ int MapReflectionFriend::ScalarMapSetItem(PyObject* _self, PyObject* key, static PyObject* ScalarMapGet(PyObject* self, PyObject* args, PyObject* kwargs) { - static char* kwlist[] = {"key", "default", nullptr}; + static const char* kwlist[] = {"key", "default", nullptr}; PyObject* key; PyObject* default_value = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist, &key, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", const_cast(kwlist), &key, &default_value)) { return NULL; } @@ -757,10 +757,10 @@ PyObject* MapReflectionFriend::MessageMapToStr(PyObject* _self) { } PyObject* MessageMapGet(PyObject* self, PyObject* args, PyObject* kwargs) { - static char* kwlist[] = {"key", "default", nullptr}; + static const char* kwlist[] = {"key", "default", nullptr}; PyObject* key; PyObject* default_value = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist, &key, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", const_cast(kwlist), &key, &default_value)) { return NULL; } diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc index 4e74386e2d..e8e1a17b97 100644 --- a/python/google/protobuf/pyext/message.cc +++ b/python/google/protobuf/pyext/message.cc @@ -196,12 +196,12 @@ static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) { } static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) { - static char *kwlist[] = {"name", "bases", "dict", 0}; + static const char *kwlist[] = {"name", "bases", "dict", 0}; PyObject *bases, *dict; const char* name; // Check arguments: (name, bases, dict) - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO!O!:type", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO!O!:type", const_cast(kwlist), &name, &PyTuple_Type, &bases, &PyDict_Type, &dict)) { @@ -546,7 +546,7 @@ PyObject* PickleError_class; // Format an error message for unexpected types. // Always return with an exception set. -void FormatTypeError(PyObject* arg, char* expected_types) { +void FormatTypeError(PyObject* arg, const char* expected_types) { // This function is often called with an exception set. // Clear it to call PyObject_Repr() in good conditions. PyErr_Clear(); @@ -1679,9 +1679,9 @@ static PyObject* InternalSerializeToString( CMessage* self, PyObject* args, PyObject* kwargs, bool require_initialized) { // Parse the "deterministic" kwarg; defaults to False. - static char* kwlist[] = { "deterministic", 0 }; + static const char* kwlist[] = { "deterministic", 0 }; PyObject* deterministic_obj = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", const_cast(kwlist), &deterministic_obj)) { return NULL; } diff --git a/python/google/protobuf/pyext/message.h b/python/google/protobuf/pyext/message.h index a1e8326512..96e06e5a3d 100644 --- a/python/google/protobuf/pyext/message.h +++ b/python/google/protobuf/pyext/message.h @@ -329,7 +329,7 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg); #define FULL_MODULE_NAME "google.protobuf.pyext._message" -void FormatTypeError(PyObject* arg, char* expected_types); +void FormatTypeError(PyObject* arg, const char* expected_types); template bool CheckAndGetInteger(PyObject* arg, T* value); bool CheckAndGetDouble(PyObject* arg, double* value); diff --git a/python/google/protobuf/pyext/message_factory.cc b/python/google/protobuf/pyext/message_factory.cc index 5fed13b943..5a10c3dc24 100644 --- a/python/google/protobuf/pyext/message_factory.cc +++ b/python/google/protobuf/pyext/message_factory.cc @@ -77,9 +77,9 @@ PyMessageFactory* NewMessageFactory(PyTypeObject* type, PyDescriptorPool* pool) } PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) { - static char* kwlist[] = {"pool", 0}; + static const char* kwlist[] = {"pool", 0}; PyObject* pool = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", kwlist, &pool)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", const_cast(kwlist), &pool)) { return NULL; } ScopedPyObjectPtr owned_pool; From 88367afa1ff1c178e33ce9e1214050638a05f4d4 Mon Sep 17 00:00:00 2001 From: Yannic Date: Tue, 2 Mar 2021 00:29:00 +0000 Subject: [PATCH 10/55] [C++] Delete StringPiecePod (#8353) Protobuf no longer supports C++ < 11, so this type is no longer required. --- src/google/protobuf/stubs/stringpiece.h | 43 ------------------- src/google/protobuf/stubs/strutil.h | 3 -- src/google/protobuf/util/internal/datapiece.h | 8 ++-- 3 files changed, 3 insertions(+), 51 deletions(-) diff --git a/src/google/protobuf/stubs/stringpiece.h b/src/google/protobuf/stubs/stringpiece.h index fbcb20afc4..0a426fec34 100644 --- a/src/google/protobuf/stubs/stringpiece.h +++ b/src/google/protobuf/stubs/stringpiece.h @@ -426,49 +426,6 @@ inline bool operator>=(StringPiece x, StringPiece y) { // allow StringPiece to be logged extern std::ostream& operator<<(std::ostream& o, StringPiece piece); -namespace internal { -// StringPiece is not a POD and can not be used in an union (pre C++11). We -// need a POD version of it. -struct StringPiecePod { - // Create from a StringPiece. - static StringPiecePod CreateFromStringPiece(StringPiece str) { - StringPiecePod pod; - pod.data_ = str.data(); - pod.size_ = str.size(); - return pod; - } - - // Cast to StringPiece. - operator StringPiece() const { return StringPiece(data_, size_); } - - bool operator==(const char* value) const { - return StringPiece(data_, size_) == StringPiece(value); - } - - char operator[](stringpiece_ssize_type i) const { - assert(0 <= i); - assert(i < size_); - return data_[i]; - } - - const char* data() const { return data_; } - - stringpiece_ssize_type size() const { - return size_; - } - - std::string ToString() const { - return std::string(data_, static_cast(size_)); - } - - explicit operator std::string() const { return ToString(); } - - private: - const char* data_; - stringpiece_ssize_type size_; -}; - -} // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h index 8ce81f28c3..31c548982e 100644 --- a/src/google/protobuf/stubs/strutil.h +++ b/src/google/protobuf/stubs/strutil.h @@ -664,9 +664,6 @@ struct PROTOBUF_EXPORT AlphaNum { AlphaNum(StringPiece str) : piece_data_(str.data()), piece_size_(str.size()) {} - AlphaNum(internal::StringPiecePod str) - : piece_data_(str.data()), piece_size_(str.size()) {} - size_t size() const { return piece_size_; } const char *data() const { return piece_data_; } diff --git a/src/google/protobuf/util/internal/datapiece.h b/src/google/protobuf/util/internal/datapiece.h index 03ea128bdb..a8fe717457 100644 --- a/src/google/protobuf/util/internal/datapiece.h +++ b/src/google/protobuf/util/internal/datapiece.h @@ -93,12 +93,12 @@ class PROTOBUF_EXPORT DataPiece { : type_(TYPE_BOOL), bool_(value), use_strict_base64_decoding_(false) {} DataPiece(StringPiece value, bool use_strict_base64_decoding) : type_(TYPE_STRING), - str_(StringPiecePod::CreateFromStringPiece(value)), + str_(value), use_strict_base64_decoding_(use_strict_base64_decoding) {} // Constructor for bytes. The second parameter is not used. DataPiece(StringPiece value, bool dummy, bool use_strict_base64_decoding) : type_(TYPE_BYTES), - str_(StringPiecePod::CreateFromStringPiece(value)), + str_(value), use_strict_base64_decoding_(use_strict_base64_decoding) {} DataPiece(const DataPiece& r) : type_(r.type_) { InternalCopy(r); } @@ -191,8 +191,6 @@ class PROTOBUF_EXPORT DataPiece { // Data type for this piece of data. Type type_; - typedef ::google::protobuf::internal::StringPiecePod StringPiecePod; - // Stored piece of data. union { int32 i32_; @@ -202,7 +200,7 @@ class PROTOBUF_EXPORT DataPiece { double double_; float float_; bool bool_; - StringPiecePod str_; + StringPiece str_; }; // Uses a stricter version of base64 decoding for byte fields. From 9d203953a9950a2f2054b9029490940859ba153f Mon Sep 17 00:00:00 2001 From: Romain Geissler Date: Thu, 18 Feb 2021 23:34:41 +0000 Subject: [PATCH 11/55] Fix gcc error: comparison of unsigned expression in '>= 0' is always true [-Werror=type-limits] This fixes the following build error: In file included from no_warning_test.cc:7: ../../src/google/protobuf/parse_context.h: In instantiation of 'const char* google::protobuf::internal::EpsCopyInputStream::AppendUntilEnd(const char*, const A&) [with A = google::protobuf::internal::EpsCopyInputStream::AppendString(const char*, std::string*)::]': ../../src/google/protobuf/parse_context.h:366:70: required from here ../../src/google/protobuf/stubs/logging.h:161:48: error: comparison of unsigned expression in '>= 0' is always true [-Werror=type-limits] 161 | #define GOOGLE_CHECK_GE(A, B) GOOGLE_CHECK((A) >= (B)) | ^ ../../src/google/protobuf/stubs/logging.h:151:5: note: in definition of macro 'GOOGLE_LOG_IF' 151 | !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL) | ^~~~~~~~~ ../../src/google/protobuf/stubs/logging.h:161:31: note: in expansion of macro 'GOOGLE_CHECK' 161 | #define GOOGLE_CHECK_GE(A, B) GOOGLE_CHECK((A) >= (B)) | ^~~~~~~~~~~~ ../../src/google/protobuf/stubs/logging.h:201:26: note: in expansion of macro 'GOOGLE_CHECK_GE' 201 | #define GOOGLE_DCHECK_GE GOOGLE_CHECK_GE | ^~~~~~~~~~~~~~~ ../../src/google/protobuf/parse_context.h:351:7: note: in expansion of macro 'GOOGLE_DCHECK_GE' 351 | GOOGLE_DCHECK_GE(chunk_size, static_cast(0)); | ^~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors --- src/google/protobuf/parse_context.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index 7966d99d57..3754f983b1 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -348,7 +348,6 @@ class PROTOBUF_EXPORT EpsCopyInputStream { if (ptr - buffer_end_ > limit_) return nullptr; while (limit_ > kSlopBytes) { size_t chunk_size = buffer_end_ + kSlopBytes - ptr; - GOOGLE_DCHECK_GE(chunk_size, static_cast(0)); append(ptr, chunk_size); ptr = Next(); if (ptr == nullptr) return limit_end_; From 630028a4c6442cfcfabf9c770870a441b3096da8 Mon Sep 17 00:00:00 2001 From: Anton Danielsson Date: Tue, 16 Feb 2021 20:59:54 +0100 Subject: [PATCH 12/55] Fix cmake install on iOS Fixes: INSTALL TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable --- cmake/install.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/install.cmake b/cmake/install.cmake index 9dd6e7710f..ef5bb13068 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -30,7 +30,9 @@ endforeach() if (protobuf_BUILD_PROTOC_BINARIES) install(TARGETS protoc EXPORT protobuf-targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT protoc) if (UNIX AND NOT APPLE) set_property(TARGET protoc PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") From a4e7b97bd609acf2b8b0eb7c936d37f2eda367ff Mon Sep 17 00:00:00 2001 From: Florian Simon Date: Thu, 25 Feb 2021 15:11:40 -0500 Subject: [PATCH 13/55] Create a CMake option to control whether or not RTTI is enabled This is useful for Conan recipes that build Protobuf, in which whatever we want to enable has to be enabled in the initial command line. Without this, the people maintaining the recipe have to patch the CMake setup of Protobuf before building the binaries. Closes #5541 --- cmake/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 52661f522d..83bbb40164 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -40,6 +40,7 @@ endif() if(WITH_PROTOC) set(protobuf_PROTOC_EXE ${WITH_PROTOC} CACHE FILEPATH "Protocol Buffer Compiler executable" FORCE) endif() +option(protobuf_DISABLE_RTTI "Remove runtime type information in the binaries" ON) option(protobuf_BUILD_TESTS "Build tests" ON) option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF) option(protobuf_BUILD_EXAMPLES "Build examples" OFF) @@ -117,6 +118,10 @@ endif() add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD) +if (protobuf_DISABLE_RTTI) + add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1) +endif() + find_package(Threads REQUIRED) if (CMAKE_USE_PTHREADS_INIT) add_definitions(-DHAVE_PTHREAD) From 3172ab8ff97aab005d7734627409faa166174232 Mon Sep 17 00:00:00 2001 From: Po-Chuan Hsieh Date: Fri, 26 Feb 2021 10:26:56 +0000 Subject: [PATCH 14/55] Fix endian.h location on FreeBSD --- src/google/protobuf/io/coded_stream.h | 2 ++ src/google/protobuf/stubs/port.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index df8c4499ad..dcbb7834a7 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -133,6 +133,8 @@ #else #ifdef __APPLE__ #include // __BYTE_ORDER +#elif defined(__FreeBSD__) +#include // __BYTE_ORDER #else #include // __BYTE_ORDER #endif diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index b7aab404ca..0f3b5aa628 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -59,6 +59,8 @@ #else #ifdef __APPLE__ #include // __BYTE_ORDER +#elif defined(__FreeBSD__) +#include // __BYTE_ORDER #else #include // __BYTE_ORDER #endif From 85e5204517779bbb6b3523ab516359f581bf0bab Mon Sep 17 00:00:00 2001 From: Yannic Date: Sat, 27 Feb 2021 15:00:59 +0100 Subject: [PATCH 15/55] [bazel] Flip --incompatible_use_com_google_googletest --- BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD b/BUILD index 1124321602..1dee9af93d 100644 --- a/BUILD +++ b/BUILD @@ -17,7 +17,7 @@ exports_files(["LICENSE"]) # TODO(yannic): Remove in 3.14.0. string_flag( name = "incompatible_use_com_google_googletest", - build_setting_default = "true", + build_setting_default = "false", values = ["true", "false"] ) From 2e7771d7a05a9416c530332f0ebd2c0522c4e6e6 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Tue, 2 Mar 2021 22:49:24 +0300 Subject: [PATCH 16/55] read_property() handler is not supposed to return NULL NULL is never expected as a result of read_property() handler, it should return &EG(uninitialized_zval) if there is no such property in the object --- php/ext/google/protobuf/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 7f27670320..0f1f4c964e 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -334,7 +334,7 @@ static zval *Message_read_property(PROTO_VAL *obj, PROTO_STR *member, Message* intern = PROTO_VAL_P(obj); const upb_fielddef *f = get_field(intern, member); - if (!f) return NULL; + if (!f) return &EG(uninitialized_zval); Message_get(intern, f, rv); return rv; } From dfa54577d65d7570593435318bb6aadc05c6bdf3 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 2 Mar 2021 12:34:41 -0800 Subject: [PATCH 17/55] [Ruby] Fixed SEGV when users pass nil messages. --- ruby/ext/google/protobuf_c/message.c | 4 +++- ruby/tests/basic.rb | 11 ++++++++--- ruby/tests/repeated_field_test.rb | 12 ------------ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c index 77b0e8b9c1..aed84bdcd0 100644 --- a/ruby/ext/google/protobuf_c/message.c +++ b/ruby/ext/google/protobuf_c/message.c @@ -1248,7 +1248,9 @@ upb_msg* Message_deep_copy(const upb_msg* msg, const upb_msgdef* m, const upb_msg* Message_GetUpbMessage(VALUE value, const upb_msgdef* m, const char* name, upb_arena* arena) { - if (value == Qnil) return NULL; + if (value == Qnil) { + rb_raise(cTypeError, "nil message not allowed here."); + } VALUE klass = CLASS_OF(value); VALUE desc_rb = rb_ivar_get(klass, descriptor_instancevar_interned); diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index 107084e664..8ddf72b81e 100755 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -52,10 +52,15 @@ module BasicTest outer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Outer").msgclass - outer_proto = outer.new( + outer.new( inners: [] - ) - outer_proto['inners'].to_s + )['inners'].to_s + + assert_raise Google::Protobuf::TypeError do + outer.new( + inners: [nil] + ).to_s + end end def test_has_field diff --git a/ruby/tests/repeated_field_test.rb b/ruby/tests/repeated_field_test.rb index 6307447bc3..1df6e1d4f1 100755 --- a/ruby/tests/repeated_field_test.rb +++ b/ruby/tests/repeated_field_test.rb @@ -339,18 +339,6 @@ class RepeatedFieldTest < Test::Unit::TestCase end end - def test_compact! - m = TestMessage.new - m.repeated_msg << TestMessage2.new(:foo => 1) - m.repeated_msg << nil - m.repeated_msg << TestMessage2.new(:foo => 2) - reference_arr = m.repeated_string.to_a - - check_self_modifying_method(m.repeated_string, reference_arr) do |arr| - arr.compact! - end - end - def test_delete m = TestMessage.new reference_arr = %w(foo bar baz) From 88243e45fc3300e7f0c50b1a1c70834249ad974d Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 2 Mar 2021 13:37:47 -0800 Subject: [PATCH 18/55] [Ruby] Fixed quadratic memory usage when appending to arrays. The code mistakenly called realloc() instead of resize() on every array append, causing quadratic memory usage. --- ruby/ext/google/protobuf_c/ruby-upb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index a7aeda2df2..61762fcd99 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -6663,10 +6663,9 @@ void upb_array_set(upb_array *arr, size_t i, upb_msgval val) { } bool upb_array_append(upb_array *arr, upb_msgval val, upb_arena *arena) { - if (!_upb_array_realloc(arr, arr->len + 1, arena)) { + if (!upb_array_resize(arr, arr->len + 1, arena)) { return false; } - arr->len++; upb_array_set(arr, arr->len - 1, val); return true; } From 1add7a7bd6db1b2c367f83864a50ebd119a04710 Mon Sep 17 00:00:00 2001 From: Florian Simon Date: Thu, 25 Feb 2021 15:11:40 -0500 Subject: [PATCH 19/55] Create a CMake option to control whether or not RTTI is enabled This is useful for Conan recipes that build Protobuf, in which whatever we want to enable has to be enabled in the initial command line. Without this, the people maintaining the recipe have to patch the CMake setup of Protobuf before building the binaries. Closes #5541 --- cmake/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 52661f522d..83bbb40164 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -40,6 +40,7 @@ endif() if(WITH_PROTOC) set(protobuf_PROTOC_EXE ${WITH_PROTOC} CACHE FILEPATH "Protocol Buffer Compiler executable" FORCE) endif() +option(protobuf_DISABLE_RTTI "Remove runtime type information in the binaries" ON) option(protobuf_BUILD_TESTS "Build tests" ON) option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF) option(protobuf_BUILD_EXAMPLES "Build examples" OFF) @@ -117,6 +118,10 @@ endif() add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD) +if (protobuf_DISABLE_RTTI) + add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1) +endif() + find_package(Threads REQUIRED) if (CMAKE_USE_PTHREADS_INIT) add_definitions(-DHAVE_PTHREAD) From 7d63b996e1b2b341f0a527d7e5ae0f153d595ce4 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 2 Mar 2021 15:20:06 -0800 Subject: [PATCH 20/55] Removed compatibility test that tries to append "nil" to repeated field. --- .../v3.0.0/tests/repeated_field_test.rb | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/ruby/compatibility_tests/v3.0.0/tests/repeated_field_test.rb b/ruby/compatibility_tests/v3.0.0/tests/repeated_field_test.rb index b4a158f37c..4f70f52dc4 100755 --- a/ruby/compatibility_tests/v3.0.0/tests/repeated_field_test.rb +++ b/ruby/compatibility_tests/v3.0.0/tests/repeated_field_test.rb @@ -326,18 +326,6 @@ class RepeatedFieldTest < Test::Unit::TestCase end end - def test_compact! - m = TestMessage.new - m.repeated_msg << TestMessage2.new(:foo => 1) - m.repeated_msg << nil - m.repeated_msg << TestMessage2.new(:foo => 2) - reference_arr = m.repeated_string.to_a - - check_self_modifying_method(m.repeated_string, reference_arr) do |arr| - arr.compact! - end - end - def test_delete m = TestMessage.new reference_arr = %w(foo bar baz) From aa41d9005bac1cd6a83387a95d22fdd10cc2a855 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Tue, 2 Mar 2021 22:49:24 +0300 Subject: [PATCH 21/55] read_property() handler is not supposed to return NULL NULL is never expected as a result of read_property() handler, it should return &EG(uninitialized_zval) if there is no such property in the object --- php/ext/google/protobuf/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 7f27670320..0f1f4c964e 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -334,7 +334,7 @@ static zval *Message_read_property(PROTO_VAL *obj, PROTO_STR *member, Message* intern = PROTO_VAL_P(obj); const upb_fielddef *f = get_field(intern, member); - if (!f) return NULL; + if (!f) return &EG(uninitialized_zval); Message_get(intern, f, rv); return rv; } From e5c067f81b0865cdd7cec9ff88568cfd5184a755 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Tue, 2 Mar 2021 15:31:13 -0800 Subject: [PATCH 22/55] Updated CHANGES.txt and PHP changelog for 3.15.4 release --- CHANGES.txt | 12 ++++++++++++ php/ext/google/protobuf/package.xml | 11 ++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d73ef274c5..092c6cf381 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,15 @@ +2021-03-02 version 3.15.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + Ruby + * Fixed SEGV when users pass nil messages (#8363) + * Fixed quadratic memory usage when appending to arrays (#8364) + + C++ + * Create a CMake option to control whether or not RTTI is enabled (#8361) + + PHP + * read_property() handler is not supposed to return NULL (#8362) + 2021-02-25 version 3.15.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) Ruby diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 75a440cd55..e72fa961bd 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -22,15 +22,8 @@ 3-Clause BSD License - New changes in 3.15.0: - * unregister INI entries and fix invalid read on shutdown (#8042) - * Fix PhpDoc comments for message accessors to include "|null". (#8136) - * fix: convert native PHP floats to single precision (#8187) - * Fixed PHP to support field numbers >=2**28. (#8235) - * feat: add support for deprecated fields to PHP compiler (#8223) - * Protect against stack overflow if the user derives from Message. (#8248) - * Fixed clone for Message, RepeatedField, and MapField. (#8245) - * Updated upb to allow nonzero offset minutes in JSON timestamps. (#8258) + New changes in 3.15.4: + * read_property() handler is not supposed to return NULL (#8362) From fd8aabf32d1d1ae3319e280fed07aa6eb24d150d Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Tue, 2 Mar 2021 15:29:59 -0800 Subject: [PATCH 23/55] Update protobuf version --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 23 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- src/Makefile.am | 2 +- src/google/protobuf/any.pb.h | 2 +- src/google/protobuf/api.pb.h | 2 +- src/google/protobuf/compiler/plugin.pb.h | 2 +- src/google/protobuf/descriptor.pb.h | 2 +- src/google/protobuf/duration.pb.h | 2 +- src/google/protobuf/empty.pb.h | 2 +- src/google/protobuf/field_mask.pb.h | 2 +- src/google/protobuf/port_def.inc | 2 +- src/google/protobuf/source_context.pb.h | 2 +- src/google/protobuf/struct.pb.h | 2 +- src/google/protobuf/stubs/common.h | 2 +- src/google/protobuf/timestamp.pb.h | 2 +- src/google/protobuf/type.pb.h | 2 +- src/google/protobuf/wrappers.pb.h | 2 +- 31 files changed, 49 insertions(+), 34 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index 1f35b0a146..829f90a9df 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Protobuf-C++' - s.version = '3.15.3' + s.version = '3.15.4' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = '3-Clause BSD License' diff --git a/Protobuf.podspec b/Protobuf.podspec index b2958e0283..d4610db4e9 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -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.15.3' + s.version = '3.15.4' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/configure.ac b/configure.ac index 2eb58902dd..3e74624b8f 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # In the SVN trunk, the version should always be the next anticipated release # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.15.3],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.15.4],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 60c7fecda9..7510b10586 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.15.3 + 3.15.4 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 3b2542ccc0..6169fed23e 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.15.3 + 3.15.4 7.2 Google Inc. diff --git a/java/bom/pom.xml b/java/bom/pom.xml index cec091173e..6c52aa7fa6 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.15.3 + 3.15.4 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index 4fc530b9db..9a004f33f6 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.3 + 3.15.4 protobuf-java diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 478ba0e15c..ac6656087c 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.3 + 3.15.4 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index 2a69b95fe4..54016968e9 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.3 + 3.15.4 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 9028b1b2f0..087882062e 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.3 + 3.15.4 protobuf-java-util diff --git a/js/package.json b/js/package.json index b5d23ebcb8..89f0e5636c 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.15.3", + "version": "3.15.4", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index e72fa961bd..de622d9410 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ protobuf-opensource@google.com yes - 2021-02-24 - + 2021-03-02 + - 3.15.3 - 3.15.3 + 3.15.4 + 3.15.4 stable @@ -843,5 +843,20 @@ G A release. + + + 3.15.4 + 3.15.4 + + + stable + stable + + 2021-03-02 + + 3-Clause BSD License + + + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index a03261c295..889ff08209 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -76,7 +76,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -#define PHP_PROTOBUF_VERSION "3.15.3" +#define PHP_PROTOBUF_VERSION "3.15.4" // ptr -> PHP object cache. This is a weak map that caches lazily-created // wrapper objects around upb types: diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 591ab09284..c8dca590e8 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.15.3 + 3.15.4 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 04a5ff6cdb..ecd917aa01 100644 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,4 +30,4 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.15.3' +__version__ = '3.15.4' diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index dde0c30183..5cec225a70 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.15.3" + s.version = "3.15.4" git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" diff --git a/src/Makefile.am b/src/Makefile.am index 442b2f11e2..c543a600de 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 26:3:0 +PROTOBUF_VERSION = 26:4:0 if GCC # Turn on all warnings except for sign comparison (we ignore sign comparison diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 70fcad5d02..7a0085a839 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index d3068c94c8..1e3b1e4056 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index f802d16b49..2311a1ffaf 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index b0faa4a3db..59c385d0a2 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 32f30c080e..4ee50e8146 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index c7079dd36e..8a3bfbe6ec 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 736920bc2e..d48167d872 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 2299d55a60..08079b29d7 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -335,7 +335,7 @@ // Shared google3/opensource definitions. ////////////////////////////////////// -#define PROTOBUF_VERSION 3015003 +#define PROTOBUF_VERSION 3015004 #define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3015000 #define PROTOBUF_MIN_PROTOC_VERSION 3015000 #define PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 9539dc5872..6c23356b9b 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 9613809e93..e1e115677e 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index b920b7ff9b..91df05e760 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -82,7 +82,7 @@ namespace internal { // The current version, represented as a single integer to make comparison // easier: major * 10^6 + minor * 10^3 + micro -#define GOOGLE_PROTOBUF_VERSION 3015003 +#define GOOGLE_PROTOBUF_VERSION 3015004 // A suffix string for alpha, beta or rc releases. Empty for stable releases. #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index c16d82ce8e..f44dab6bce 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 88918c7339..252679ccd7 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index e71d733f69..6bca9ed6eb 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. From 33905ec87bd49e257cba21888e99ea0278705d10 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 3 Mar 2021 12:36:13 -0800 Subject: [PATCH 24/55] Fixed the Java Lite build. --- java/lite/generate-test-sources-build.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/java/lite/generate-test-sources-build.xml b/java/lite/generate-test-sources-build.xml index 62bca93c86..65e62ce4fb 100644 --- a/java/lite/generate-test-sources-build.xml +++ b/java/lite/generate-test-sources-build.xml @@ -4,6 +4,7 @@ + From 82f5ecd955391bf6fe35ed08214dd7287764a60d Mon Sep 17 00:00:00 2001 From: Yannic Date: Wed, 3 Mar 2021 23:07:10 +0100 Subject: [PATCH 25/55] Revert "[bazel] Flip --incompatible_use_com_google_googletest" This reverts commit 85e5204517779bbb6b3523ab516359f581bf0bab. --- BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD b/BUILD index 1dee9af93d..1124321602 100644 --- a/BUILD +++ b/BUILD @@ -17,7 +17,7 @@ exports_files(["LICENSE"]) # TODO(yannic): Remove in 3.14.0. string_flag( name = "incompatible_use_com_google_googletest", - build_setting_default = "false", + build_setting_default = "true", values = ["true", "false"] ) From 5d0c30934bb6a6c1d387b549f5af3a4efcebe2ef Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Thu, 4 Mar 2021 13:25:55 +0300 Subject: [PATCH 26/55] Added abilty to pass options to protoc executable from cmake --- cmake/protobuf-config.cmake.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/protobuf-config.cmake.in b/cmake/protobuf-config.cmake.in index fac5efe440..9197625dc2 100644 --- a/cmake/protobuf-config.cmake.in +++ b/cmake/protobuf-config.cmake.in @@ -15,7 +15,7 @@ function(protobuf_generate) if(COMMAND target_sources) list(APPEND _singleargs TARGET) endif() - set(_multiargs PROTOS IMPORT_DIRS GENERATE_EXTENSIONS) + set(_multiargs PROTOS IMPORT_DIRS GENERATE_EXTENSIONS PROTOC_OPTIONS) cmake_parse_arguments(protobuf_generate "${_options}" "${_singleargs}" "${_multiargs}" "${ARGN}") @@ -130,9 +130,9 @@ function(protobuf_generate) add_custom_command( OUTPUT ${_generated_srcs} COMMAND protobuf::protoc - ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_plugin} ${_protobuf_include_path} ${_abs_file} + ARGS ${protobuf_generate_PROTOC_OPTIONS} --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_plugin} ${_protobuf_include_path} ${_abs_file} DEPENDS ${_abs_file} protobuf::protoc - COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}" + COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}. Custom options: ${protobuf_generate_PROTOC_OPTIONS}" VERBATIM ) endforeach() From 9b5e357df578d33b3daca0703d6bf019d40fcd92 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Thu, 4 Mar 2021 09:12:29 -0800 Subject: [PATCH 27/55] Fixed quadratic memory use in array append for PHP and Ruby. --- php/ext/google/protobuf/php-upb.c | 3 +-- ruby/ext/google/protobuf_c/ruby-upb.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index c56a567ca3..913dfad7e9 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -7047,10 +7047,9 @@ void upb_array_set(upb_array *arr, size_t i, upb_msgval val) { } bool upb_array_append(upb_array *arr, upb_msgval val, upb_arena *arena) { - if (!_upb_array_realloc(arr, arr->len + 1, arena)) { + if (!upb_array_resize(arr, arr->len + 1, arena)) { return false; } - arr->len++; upb_array_set(arr, arr->len - 1, val); return true; } diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index a7aeda2df2..61762fcd99 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -6663,10 +6663,9 @@ void upb_array_set(upb_array *arr, size_t i, upb_msgval val) { } bool upb_array_append(upb_array *arr, upb_msgval val, upb_arena *arena) { - if (!_upb_array_realloc(arr, arr->len + 1, arena)) { + if (!upb_array_resize(arr, arr->len + 1, arena)) { return false; } - arr->len++; upb_array_set(arr, arr->len - 1, val); return true; } From b6facc69ea0f1515b9bf522634bb6ab19031729d Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 1 Mar 2021 10:01:35 -0500 Subject: [PATCH 28/55] docs: update version --- java/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/README.md b/java/README.md index c8050893e0..c3434144b1 100644 --- a/java/README.md +++ b/java/README.md @@ -23,7 +23,7 @@ If you are using Maven, use the following: com.google.protobuf protobuf-java - 3.11.0 + 3.15.3 ``` @@ -37,7 +37,7 @@ protobuf-java-util package: com.google.protobuf protobuf-java-util - 3.11.0 + 3.15.3 ``` From b9a036b444365b2ffa4928a02f069ff62b70ec39 Mon Sep 17 00:00:00 2001 From: Florian Simon Date: Thu, 4 Mar 2021 11:39:28 -0500 Subject: [PATCH 29/55] Do not disable RTTI by default in the CMake build --- cmake/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 83bbb40164..5c3b6e4512 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -40,12 +40,12 @@ endif() if(WITH_PROTOC) set(protobuf_PROTOC_EXE ${WITH_PROTOC} CACHE FILEPATH "Protocol Buffer Compiler executable" FORCE) endif() -option(protobuf_DISABLE_RTTI "Remove runtime type information in the binaries" ON) option(protobuf_BUILD_TESTS "Build tests" ON) option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF) option(protobuf_BUILD_EXAMPLES "Build examples" OFF) option(protobuf_BUILD_PROTOC_BINARIES "Build libprotoc and protoc compiler" ON) option(protobuf_BUILD_LIBPROTOC "Build libprotoc" OFF) +option(protobuf_DISABLE_RTTI "Remove runtime type information in the binaries" OFF) if (BUILD_SHARED_LIBS) set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON) else (BUILD_SHARED_LIBS) From 87dd07b4367b7676af42105d0d102f4e536c248b Mon Sep 17 00:00:00 2001 From: Alexander Shadchin Date: Thu, 4 Mar 2021 22:00:41 +0300 Subject: [PATCH 30/55] Switch on "new" buffer API (#8339) "Old" buffer API will removed in Python 3.10. This is also fix #7930. --- python/google/protobuf/internal/message_test.py | 9 +-------- python/google/protobuf/internal/python_message.py | 6 ------ python/google/protobuf/pyext/descriptor.cc | 2 +- python/google/protobuf/pyext/message.cc | 12 ++++++------ python/tox.ini | 7 +++---- 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/python/google/protobuf/internal/message_test.py b/python/google/protobuf/internal/message_test.py index feff228fb6..77122a2875 100755 --- a/python/google/protobuf/internal/message_test.py +++ b/python/google/protobuf/internal/message_test.py @@ -841,8 +841,7 @@ class MessageTest(unittest.TestCase): m1.MergeFromString(m2.SerializeToString()) self.assertEqual(1, m1.optional_nested_message.bb) - @unittest.skipIf(six.PY2, 'memoryview objects are not supported on py2') - def testMergeFromStringUsingMemoryViewWorksInPy3(self, message_module): + def testMergeFromStringUsingMemoryView(self, message_module): m2 = message_module.TestAllTypes() m2.optional_string = 'scalar string' m2.repeated_string.append('repeated string') @@ -864,12 +863,6 @@ class MessageTest(unittest.TestCase): self.assertIsInstance(m1.optional_string, six.text_type) self.assertIsInstance(m1.repeated_string[0], six.text_type) - @unittest.skipIf(six.PY3, 'memoryview is supported by py3') - def testMergeFromStringUsingMemoryViewIsPy2Error(self, message_module): - memview = memoryview(b'') - with self.assertRaises(TypeError): - message_module.TestAllTypes.FromString(memview) - def testMergeFromEmpty(self, message_module): m1 = message_module.TestAllTypes() # Cpp extension will lazily create a sub message which is immutable. diff --git a/python/google/protobuf/internal/python_message.py b/python/google/protobuf/internal/python_message.py index d1f4dcde8e..99d2f078de 100644 --- a/python/google/protobuf/internal/python_message.py +++ b/python/google/protobuf/internal/python_message.py @@ -1133,12 +1133,6 @@ def _AddSerializePartialToStringMethod(message_descriptor, cls): def _AddMergeFromStringMethod(message_descriptor, cls): """Helper for _AddMessageMethods().""" def MergeFromString(self, serialized): - if isinstance(serialized, memoryview) and six.PY2: - raise TypeError( - 'memoryview not supported in Python 2 with the pure Python proto ' - 'implementation: this is to maintain compatibility with the C++ ' - 'implementation') - serialized = memoryview(serialized) length = len(serialized) try: diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc index 75f1760ccf..ab482da32f 100644 --- a/python/google/protobuf/pyext/descriptor.cc +++ b/python/google/protobuf/pyext/descriptor.cc @@ -248,7 +248,7 @@ static PyObject* GetOrBuildOptions(const DescriptorClass *descriptor) { return NULL; } ScopedPyObjectPtr value( - PyEval_CallObject(message_class->AsPyObject(), NULL)); + PyObject_Call(message_class->AsPyObject(), NULL, NULL)); Py_DECREF(message_class); if (value == NULL) { return NULL; diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc index e8e1a17b97..d3fc477d0f 100644 --- a/python/google/protobuf/pyext/message.cc +++ b/python/google/protobuf/pyext/message.cc @@ -1927,9 +1927,8 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg) { } static PyObject* MergeFromString(CMessage* self, PyObject* arg) { - const void* data; - Py_ssize_t data_length; - if (PyObject_AsReadBuffer(arg, &data, &data_length) < 0) { + Py_buffer data; + if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) < 0) { return NULL; } @@ -1942,7 +1941,8 @@ static PyObject* MergeFromString(CMessage* self, PyObject* arg) { const char* ptr; internal::ParseContext ctx( depth, false, &ptr, - StringPiece(static_cast(data), data_length)); + StringPiece(static_cast(data.buf), data.len)); + PyBuffer_Release(&data); ctx.data().pool = factory->pool->pool; ctx.data().factory = factory->message_factory; @@ -1968,9 +1968,9 @@ static PyObject* MergeFromString(CMessage* self, PyObject* arg) { // TODO(jieluo): Raise error and return NULL instead. // b/27494216 PyErr_Warn(nullptr, "Unexpected end-group tag: Not all data was converted"); - return PyInt_FromLong(data_length - ctx.BytesUntilLimit(ptr)); + return PyInt_FromLong(data.len - ctx.BytesUntilLimit(ptr)); } - return PyInt_FromLong(data_length); + return PyInt_FromLong(data.len); } static PyObject* ParseFromString(CMessage* self, PyObject* arg) { diff --git a/python/tox.ini b/python/tox.ini index 9fabb6ddbb..f9eee920fd 100644 --- a/python/tox.ini +++ b/python/tox.ini @@ -14,10 +14,9 @@ setenv = commands = python setup.py -q build_py python: python setup.py -q build - # --warnings_as_errors disabled until we update the Python C extension. See: - # https://github.com/protocolbuffers/protobuf/issues/7930 - # cpp: python setup.py -q build --cpp_implementation --warnings_as_errors --compile_static_extension - cpp: python setup.py -q build --cpp_implementation --compile_static_extension + # --warnings_as_errors disabled for Python 2.7 because _POSIX_C_SOURCE and _XOPEN_SOURCE are redefined + py27-cpp: python setup.py -q build --cpp_implementation --compile_static_extension + py{33,34,35,36,37,38,39}-cpp: python setup.py -q build --cpp_implementation --warnings_as_errors --compile_static_extension python: python setup.py -q test -q cpp: python setup.py -q test -q --cpp_implementation python: python setup.py -q test_conformance From 5702d51ec0ef87d2dd6198cf6fcade8dc850a857 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Thu, 4 Mar 2021 10:57:10 -0800 Subject: [PATCH 31/55] Updated CHANGES.txt and PHP release notes for 3.15.5 --- CHANGES.txt | 11 +++++++++++ php/ext/google/protobuf/package.xml | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 092c6cf381..8e77f6abeb 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,14 @@ +2021-03-04 version 3.15.5 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + Ruby + * Fixed quadratic memory use in array append (#8379) + + PHP + * Fixed quadratic memory use in array append (#8379) + + C++ + * Do not disable RTTI by default in the CMake build (#8377) + 2021-03-02 version 3.15.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) Ruby diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index de622d9410..3fc370d8d8 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -22,8 +22,8 @@ 3-Clause BSD License - New changes in 3.15.4: - * read_property() handler is not supposed to return NULL (#8362) + New changes in 3.15.5: + * Fixed quadratic memory use in array append (#8379) From 4fff47a41811eeaef8add8def480062282292ce5 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Thu, 4 Mar 2021 10:50:28 -0800 Subject: [PATCH 32/55] Update protobuf version --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 23 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- src/Makefile.am | 2 +- src/google/protobuf/any.pb.h | 2 +- src/google/protobuf/api.pb.h | 2 +- src/google/protobuf/compiler/plugin.pb.h | 2 +- src/google/protobuf/descriptor.pb.h | 2 +- src/google/protobuf/duration.pb.h | 2 +- src/google/protobuf/empty.pb.h | 2 +- src/google/protobuf/field_mask.pb.h | 2 +- src/google/protobuf/port_def.inc | 2 +- src/google/protobuf/source_context.pb.h | 2 +- src/google/protobuf/struct.pb.h | 2 +- src/google/protobuf/stubs/common.h | 2 +- src/google/protobuf/timestamp.pb.h | 2 +- src/google/protobuf/type.pb.h | 2 +- src/google/protobuf/wrappers.pb.h | 2 +- 31 files changed, 49 insertions(+), 34 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index 829f90a9df..e76911cc3f 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Protobuf-C++' - s.version = '3.15.4' + s.version = '3.15.5' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = '3-Clause BSD License' diff --git a/Protobuf.podspec b/Protobuf.podspec index d4610db4e9..7864d2c232 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -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.15.4' + s.version = '3.15.5' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/configure.ac b/configure.ac index 3e74624b8f..cb0fc63459 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # In the SVN trunk, the version should always be the next anticipated release # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.15.4],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.15.5],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 7510b10586..87acdfeefe 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.15.4 + 3.15.5 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 6169fed23e..f7cf3cfd17 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.15.4 + 3.15.5 7.2 Google Inc. diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 6c52aa7fa6..33aa28195f 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.15.4 + 3.15.5 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index 9a004f33f6..ffcbfe3862 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.4 + 3.15.5 protobuf-java diff --git a/java/lite/pom.xml b/java/lite/pom.xml index ac6656087c..6a011d7708 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.4 + 3.15.5 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index 54016968e9..654f9a4329 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.4 + 3.15.5 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 087882062e..1c004eeaf5 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.4 + 3.15.5 protobuf-java-util diff --git a/js/package.json b/js/package.json index 89f0e5636c..0d9266252e 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.15.4", + "version": "3.15.5", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 3fc370d8d8..4d322769f7 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ protobuf-opensource@google.com yes - 2021-03-02 - + 2021-03-04 + - 3.15.4 - 3.15.4 + 3.15.5 + 3.15.5 stable @@ -858,5 +858,20 @@ G A release. + + + 3.15.5 + 3.15.5 + + + stable + stable + + 2021-03-04 + + 3-Clause BSD License + + + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 889ff08209..104a0d6ff7 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -76,7 +76,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -#define PHP_PROTOBUF_VERSION "3.15.4" +#define PHP_PROTOBUF_VERSION "3.15.5" // ptr -> PHP object cache. This is a weak map that caches lazily-created // wrapper objects around upb types: diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index c8dca590e8..ba9eaf8ac5 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.15.4 + 3.15.5 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index ecd917aa01..8c49968e59 100644 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,4 +30,4 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.15.4' +__version__ = '3.15.5' diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 5cec225a70..7149cf4b2d 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.15.4" + s.version = "3.15.5" git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" diff --git a/src/Makefile.am b/src/Makefile.am index c543a600de..a59971a94b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 26:4:0 +PROTOBUF_VERSION = 26:5:0 if GCC # Turn on all warnings except for sign comparison (we ignore sign comparison diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 7a0085a839..76406e6b05 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 1e3b1e4056..42634c6cb9 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 2311a1ffaf..026619f67e 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 59c385d0a2..4bfe37e05a 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 4ee50e8146..e87e7b6d1c 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 8a3bfbe6ec..9703b50028 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index d48167d872..99fc7237e3 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 08079b29d7..42a7a66c81 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -335,7 +335,7 @@ // Shared google3/opensource definitions. ////////////////////////////////////// -#define PROTOBUF_VERSION 3015004 +#define PROTOBUF_VERSION 3015005 #define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3015000 #define PROTOBUF_MIN_PROTOC_VERSION 3015000 #define PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 6c23356b9b..4a553e4d77 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index e1e115677e..0758c9cb92 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 91df05e760..7b380f21ff 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -82,7 +82,7 @@ namespace internal { // The current version, represented as a single integer to make comparison // easier: major * 10^6 + minor * 10^3 + micro -#define GOOGLE_PROTOBUF_VERSION 3015004 +#define GOOGLE_PROTOBUF_VERSION 3015005 // A suffix string for alpha, beta or rc releases. Empty for stable releases. #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index f44dab6bce..325b33dcce 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 252679ccd7..4cff1f48dc 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 6bca9ed6eb..65831786f8 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. From bb322c2b39c1a98f78a5a433afe7a33cbae379a6 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 5 Mar 2021 08:23:42 -0800 Subject: [PATCH 33/55] [Ruby] Fixed bug in string comparison logic. --- ruby/ext/google/protobuf_c/convert.c | 2 +- ruby/tests/common_tests.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ruby/ext/google/protobuf_c/convert.c b/ruby/ext/google/protobuf_c/convert.c index bc3e35a5ed..2fddc09629 100644 --- a/ruby/ext/google/protobuf_c/convert.c +++ b/ruby/ext/google/protobuf_c/convert.c @@ -315,7 +315,7 @@ bool Msgval_IsEqual(upb_msgval val1, upb_msgval val2, TypeInfo type_info) { return memcmp(&val1, &val2, 8) == 0; case UPB_TYPE_STRING: case UPB_TYPE_BYTES: - return val1.str_val.size != val2.str_val.size || + return val1.str_val.size == val2.str_val.size && memcmp(val1.str_val.data, val2.str_val.data, val1.str_val.size) == 0; case UPB_TYPE_MESSAGE: diff --git a/ruby/tests/common_tests.rb b/ruby/tests/common_tests.rb index 1957422fa9..40c7726d83 100644 --- a/ruby/tests/common_tests.rb +++ b/ruby/tests/common_tests.rb @@ -436,6 +436,18 @@ module CommonTests end end + def test_b_8385 + m1 = Google::Protobuf::Map.new(:string, :string) + m2 = Google::Protobuf::Map.new(:string, :string) + + assert_equal m1, m2 + + m1["counter"] = "a" + m2["counter"] = "aa" + + assert_not_equal m1, m2 + end + def test_map_ctor m = Google::Protobuf::Map.new(:string, :int32, {"a" => 1, "b" => 2, "c" => 3}) From 8d1d530c511dcfa502fba0ef9a58e8971d2b62a4 Mon Sep 17 00:00:00 2001 From: Jiro Nishiguchi Date: Mon, 8 Mar 2021 15:40:03 +0900 Subject: [PATCH 34/55] Fix typo in docs/implementing_proto3_presence.md --- docs/implementing_proto3_presence.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/implementing_proto3_presence.md b/docs/implementing_proto3_presence.md index 73f21a3829..ae8b369579 100644 --- a/docs/implementing_proto3_presence.md +++ b/docs/implementing_proto3_presence.md @@ -261,7 +261,7 @@ bool FieldHasPresence(const google::protobuf::FieldDescriptor* field) { Old: ```c++ -bool FieldIsInOneof(const google::protobuf::FielDescriptor* field) { +bool FieldIsInOneof(const google::protobuf::FieldDescriptor* field) { return field->containing_oneof() != nullptr; } ``` @@ -269,7 +269,7 @@ bool FieldIsInOneof(const google::protobuf::FielDescriptor* field) { New: ```c++ -bool FieldIsInOneof(const google::protobuf::FielDescriptor* field) { +bool FieldIsInOneof(const google::protobuf::FieldDescriptor* field) { // real_containing_oneof() returns nullptr for synthetic oneofs. return field->real_containing_oneof() != nullptr; } From 6f4573afbd3f01958d5c2898d8b75c17f323ad11 Mon Sep 17 00:00:00 2001 From: Galen Warren Date: Sat, 6 Mar 2021 10:47:58 -0500 Subject: [PATCH 35/55] docs: register Coach Client Connect extension number (1107) --- docs/options.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/options.md b/docs/options.md index 907fe5aa02..d186a52234 100644 --- a/docs/options.md +++ b/docs/options.md @@ -268,3 +268,7 @@ with info about your project (name and website) so we can add an entry for you. 1. Protoc-gen-sanitize * Website: https://github.com/Intrinsec/protoc-gen-sanitize * Extension: 1102-1106 + +1. Coach Client Connect (planned release in March 2021) + * Website: https://www.coachclientconnect.com + * Extension: 1107 From 59ea5c8f19de47dc15cbce2e2e97d9de01d50fb9 Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Sun, 28 Feb 2021 12:18:52 +0100 Subject: [PATCH 36/55] [C++] Refactor util::Status This change refactors util::Status to have a similar shape as the recently open-sourced absl::Status. This will allow Protobuf to eventually use absl::Status and reduce the codesize. Note that there is more work required before absl::Status can be used. --- BUILD | 2 +- cmake/libprotobuf-lite.cmake | 2 +- src/Makefile.am | 2 +- .../protobuf/stubs/{ => internal}/status.cc | 60 ++++----- src/google/protobuf/stubs/internal/status.h | 119 ++++++++++++++++++ src/google/protobuf/stubs/logging.h | 4 +- src/google/protobuf/stubs/status.h | 93 ++------------ src/google/protobuf/stubs/status_test.cc | 10 +- src/google/protobuf/stubs/statusor.h | 13 +- .../protobuf/util/internal/datapiece.cc | 1 - .../util/internal/json_stream_parser_test.cc | 2 +- .../util/internal/protostream_objectsource.cc | 5 +- 12 files changed, 180 insertions(+), 133 deletions(-) rename src/google/protobuf/stubs/{ => internal}/status.cc (73%) create mode 100644 src/google/protobuf/stubs/internal/status.h diff --git a/BUILD b/BUILD index 1124321602..9b4b2fbd02 100644 --- a/BUILD +++ b/BUILD @@ -183,7 +183,7 @@ cc_library( "src/google/protobuf/stubs/bytestream.cc", "src/google/protobuf/stubs/common.cc", "src/google/protobuf/stubs/int128.cc", - "src/google/protobuf/stubs/status.cc", + "src/google/protobuf/stubs/internal/status.cc", "src/google/protobuf/stubs/statusor.cc", "src/google/protobuf/stubs/stringpiece.cc", "src/google/protobuf/stubs/stringprintf.cc", diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake index 6d325d5dca..bbd3c11cb7 100644 --- a/cmake/libprotobuf-lite.cmake +++ b/cmake/libprotobuf-lite.cmake @@ -20,7 +20,7 @@ set(libprotobuf_lite_files ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream.cc ${protobuf_source_dir}/src/google/protobuf/stubs/common.cc ${protobuf_source_dir}/src/google/protobuf/stubs/int128.cc - ${protobuf_source_dir}/src/google/protobuf/stubs/status.cc + ${protobuf_source_dir}/src/google/protobuf/stubs/internal/status.cc ${protobuf_source_dir}/src/google/protobuf/stubs/statusor.cc ${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece.cc ${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf.cc diff --git a/src/Makefile.am b/src/Makefile.am index a59971a94b..207e6c92b1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -185,7 +185,7 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/io/io_win32.cc \ google/protobuf/stubs/map_util.h \ google/protobuf/stubs/mathutil.h \ - google/protobuf/stubs/status.cc \ + google/protobuf/stubs/internal/status.cc \ google/protobuf/stubs/status.h \ google/protobuf/stubs/status_macros.h \ google/protobuf/stubs/statusor.cc \ diff --git a/src/google/protobuf/stubs/status.cc b/src/google/protobuf/stubs/internal/status.cc similarity index 73% rename from src/google/protobuf/stubs/status.cc rename to src/google/protobuf/stubs/internal/status.cc index 03b37c365b..731e1084e1 100644 --- a/src/google/protobuf/stubs/status.cc +++ b/src/google/protobuf/stubs/internal/status.cc @@ -37,42 +37,44 @@ namespace google { namespace protobuf { namespace util { -namespace error { -inline std::string CodeEnumToString(error::Code code) { +namespace status_internal { +namespace { + +inline std::string StatusCodeToString(StatusCode code) { switch (code) { - case OK: + case StatusCode::kOk: return "OK"; - case CANCELLED: + case StatusCode::kCancelled: return "CANCELLED"; - case UNKNOWN: + case StatusCode::kUnknown: return "UNKNOWN"; - case INVALID_ARGUMENT: + case StatusCode::kInvalidArgument: return "INVALID_ARGUMENT"; - case DEADLINE_EXCEEDED: + case StatusCode::kDeadlineExceeded: return "DEADLINE_EXCEEDED"; - case NOT_FOUND: + case StatusCode::kNotFound: return "NOT_FOUND"; - case ALREADY_EXISTS: + case StatusCode::kAlreadyExists: return "ALREADY_EXISTS"; - case PERMISSION_DENIED: + case StatusCode::kPermissionDenied: return "PERMISSION_DENIED"; - case UNAUTHENTICATED: + case StatusCode::kUnauthenticated: return "UNAUTHENTICATED"; - case RESOURCE_EXHAUSTED: + case StatusCode::kResourceExhausted: return "RESOURCE_EXHAUSTED"; - case FAILED_PRECONDITION: + case StatusCode::kFailedPrecondition: return "FAILED_PRECONDITION"; - case ABORTED: + case StatusCode::kAborted: return "ABORTED"; - case OUT_OF_RANGE: + case StatusCode::kOutOfRange: return "OUT_OF_RANGE"; - case UNIMPLEMENTED: + case StatusCode::kUnimplemented: return "UNIMPLEMENTED"; - case INTERNAL: + case StatusCode::kInternal: return "INTERNAL"; - case UNAVAILABLE: + case StatusCode::kUnavailable: return "UNAVAILABLE"; - case DATA_LOSS: + case StatusCode::kDataLoss: return "DATA_LOSS"; } @@ -80,18 +82,19 @@ inline std::string CodeEnumToString(error::Code code) { // above switch. return "UNKNOWN"; } -} // namespace error. + +} // namespace const Status Status::OK = Status(); -const Status Status::CANCELLED = Status(error::CANCELLED, ""); -const Status Status::UNKNOWN = Status(error::UNKNOWN, ""); +const Status Status::CANCELLED = Status(StatusCode::kCancelled, ""); +const Status Status::UNKNOWN = Status(StatusCode::kUnknown, ""); -Status::Status() : error_code_(error::OK) { +Status::Status() : error_code_(StatusCode::kOk) { } -Status::Status(error::Code error_code, StringPiece error_message) +Status::Status(StatusCode error_code, StringPiece error_message) : error_code_(error_code) { - if (error_code != error::OK) { + if (error_code != StatusCode::kOk) { error_message_ = error_message.ToString(); } } @@ -112,13 +115,13 @@ bool Status::operator==(const Status& x) const { } std::string Status::ToString() const { - if (error_code_ == error::OK) { + if (error_code_ == StatusCode::kOk) { return "OK"; } else { if (error_message_.empty()) { - return error::CodeEnumToString(error_code_); + return StatusCodeToString(error_code_); } else { - return error::CodeEnumToString(error_code_) + ":" + + return StatusCodeToString(error_code_) + ":" + error_message_; } } @@ -129,6 +132,7 @@ std::ostream& operator<<(std::ostream& os, const Status& x) { return os; } +} // namespace status_internal } // namespace util } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/internal/status.h b/src/google/protobuf/stubs/internal/status.h new file mode 100644 index 0000000000..79c1f80795 --- /dev/null +++ b/src/google/protobuf/stubs/internal/status.h @@ -0,0 +1,119 @@ +// 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. + +#ifndef GOOGLE_PROTOBUF_STUBS_INTERNAL_STATUS_H_ +#define GOOGLE_PROTOBUF_STUBS_INTERNAL_STATUS_H_ + +#include + +#include + +#include + +namespace google { +namespace protobuf { +namespace util { +namespace status_internal { + +// These values must match error codes defined in google/rpc/code.proto. +enum class StatusCode : int { + kOk = 0, + kCancelled = 1, + kUnknown = 2, + kInvalidArgument = 3, + kDeadlineExceeded = 4, + kNotFound = 5, + kAlreadyExists = 6, + kPermissionDenied = 7, + kUnauthenticated = 16, + kResourceExhausted = 8, + kFailedPrecondition = 9, + kAborted = 10, + kOutOfRange = 11, + kUnimplemented = 12, + kInternal = 13, + kUnavailable = 14, + kDataLoss = 15, +}; + +class PROTOBUF_EXPORT Status { + public: + // Creates a "successful" status. + Status(); + + // Create a status in the canonical error space with the specified + // code, and error message. If "code == 0", error_message is + // ignored and a Status object identical to Status::kOk is + // constructed. + Status(StatusCode error_code, StringPiece error_message); + Status(const Status&); + Status& operator=(const Status& x); + ~Status() {} + + // Some pre-defined Status objects + static const Status OK; // Identical to 0-arg constructor + static const Status CANCELLED; + static const Status UNKNOWN; + + // Accessor + bool ok() const { + return error_code_ == StatusCode::kOk; + } + StatusCode code() const { + return error_code_; + } + StringPiece message() const { + return error_message_; + } + + bool operator==(const Status& x) const; + bool operator!=(const Status& x) const { + return !operator==(x); + } + + // Return a combination of the error code name and message. + std::string ToString() const; + + private: + StatusCode error_code_; + std::string error_message_; +}; + +// Prints a human-readable representation of 'x' to 'os'. +PROTOBUF_EXPORT std::ostream& operator<<(std::ostream& os, const Status& x); + +} // namespace status_internal +} // namespace util +} // namespace protobuf +} // namespace google + +#include + +#endif // GOOGLE_PROTOBUF_STUBS_INTERNAL_STATUS_H_ diff --git a/src/google/protobuf/stubs/logging.h b/src/google/protobuf/stubs/logging.h index f37048d677..110ccdc950 100644 --- a/src/google/protobuf/stubs/logging.h +++ b/src/google/protobuf/stubs/logging.h @@ -33,6 +33,7 @@ #include #include +#include #include @@ -64,9 +65,6 @@ enum LogLevel { }; class StringPiece; -namespace util { -class Status; -} class uint128; namespace internal { diff --git a/src/google/protobuf/stubs/status.h b/src/google/protobuf/stubs/status.h index bededad541..67951abfd6 100644 --- a/src/google/protobuf/stubs/status.h +++ b/src/google/protobuf/stubs/status.h @@ -27,99 +27,32 @@ // 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. + #ifndef GOOGLE_PROTOBUF_STUBS_STATUS_H_ #define GOOGLE_PROTOBUF_STUBS_STATUS_H_ -#include -#include - -#include -#include - -#include +#include namespace google { namespace protobuf { namespace util { -namespace error { -// These values must match error codes defined in google/rpc/code.proto. -enum Code { - OK = 0, - CANCELLED = 1, - UNKNOWN = 2, - INVALID_ARGUMENT = 3, - DEADLINE_EXCEEDED = 4, - NOT_FOUND = 5, - ALREADY_EXISTS = 6, - PERMISSION_DENIED = 7, - UNAUTHENTICATED = 16, - RESOURCE_EXHAUSTED = 8, - FAILED_PRECONDITION = 9, - ABORTED = 10, - OUT_OF_RANGE = 11, - UNIMPLEMENTED = 12, - INTERNAL = 13, - UNAVAILABLE = 14, - DATA_LOSS = 15, -}; -} // namespace error - -class PROTOBUF_EXPORT Status { - public: - // Creates a "successful" status. - Status(); - - // Create a status in the canonical error space with the specified - // code, and error message. If "code == 0", error_message is - // ignored and a Status object identical to Status::OK is - // constructed. - Status(error::Code error_code, StringPiece error_message); - Status(const Status&); - Status& operator=(const Status& x); - ~Status() {} - // Some pre-defined Status objects - static const Status OK; // Identical to 0-arg constructor - static const Status CANCELLED; - static const Status UNKNOWN; +using ::google::protobuf::util::status_internal::Status; +using ::google::protobuf::util::status_internal::StatusCode; - // Accessor - bool ok() const { - return error_code_ == error::OK; - } - int error_code() const { - return error_code_; - } - error::Code code() const { - return error_code_; - } - StringPiece error_message() const { - return error_message_; - } - StringPiece message() const { - return error_message_; - } - - bool operator==(const Status& x) const; - bool operator!=(const Status& x) const { - return !operator==(x); - } - - // Return a combination of the error code name and message. - std::string ToString() const; - - private: - error::Code error_code_; - std::string error_message_; -}; +namespace error { -// Prints a human-readable representation of 'x' to 'os'. -PROTOBUF_EXPORT std::ostream& operator<<(std::ostream& os, const Status& x); +// TODO(yannic): Remove these. +constexpr StatusCode OK = StatusCode::kOk; +constexpr StatusCode CANCELLED = StatusCode::kCancelled; +constexpr StatusCode UNKNOWN = StatusCode::kUnknown; +constexpr StatusCode INVALID_ARGUMENT = StatusCode::kInvalidArgument; +constexpr StatusCode NOT_FOUND = StatusCode::kNotFound; +constexpr StatusCode INTERNAL = StatusCode::kInternal; +} // namespace error } // namespace util } // namespace protobuf } // namespace google -#include - #endif // GOOGLE_PROTOBUF_STUBS_STATUS_H_ diff --git a/src/google/protobuf/stubs/status_test.cc b/src/google/protobuf/stubs/status_test.cc index 8f4398c9c9..ce486809db 100644 --- a/src/google/protobuf/stubs/status_test.cc +++ b/src/google/protobuf/stubs/status_test.cc @@ -39,17 +39,13 @@ namespace protobuf { namespace { TEST(Status, Empty) { util::Status status; - EXPECT_EQ(util::error::OK, util::Status::OK.error_code()); EXPECT_EQ(util::error::OK, util::Status::OK.code()); EXPECT_EQ("OK", util::Status::OK.ToString()); } TEST(Status, GenericCodes) { - EXPECT_EQ(util::error::OK, util::Status::OK.error_code()); EXPECT_EQ(util::error::OK, util::Status::OK.code()); - EXPECT_EQ(util::error::CANCELLED, util::Status::CANCELLED.error_code()); EXPECT_EQ(util::error::CANCELLED, util::Status::CANCELLED.code()); - EXPECT_EQ(util::error::UNKNOWN, util::Status::UNKNOWN.error_code()); EXPECT_EQ(util::error::UNKNOWN, util::Status::UNKNOWN.code()); } @@ -69,17 +65,17 @@ TEST(Status, CheckOK) { TEST(Status, ErrorMessage) { util::Status status(util::error::INVALID_ARGUMENT, ""); EXPECT_FALSE(status.ok()); - EXPECT_EQ("", status.error_message().ToString()); + EXPECT_EQ("", status.message().ToString()); EXPECT_EQ("", status.message().ToString()); EXPECT_EQ("INVALID_ARGUMENT", status.ToString()); status = util::Status(util::error::INVALID_ARGUMENT, "msg"); EXPECT_FALSE(status.ok()); - EXPECT_EQ("msg", status.error_message().ToString()); + EXPECT_EQ("msg", status.message().ToString()); EXPECT_EQ("msg", status.message().ToString()); EXPECT_EQ("INVALID_ARGUMENT:msg", status.ToString()); status = util::Status(util::error::OK, "msg"); EXPECT_TRUE(status.ok()); - EXPECT_EQ("", status.error_message().ToString()); + EXPECT_EQ("", status.message().ToString()); EXPECT_EQ("", status.message().ToString()); EXPECT_EQ("OK", status.ToString()); } diff --git a/src/google/protobuf/stubs/statusor.h b/src/google/protobuf/stubs/statusor.h index c02e89a9f0..c3748eacc1 100644 --- a/src/google/protobuf/stubs/statusor.h +++ b/src/google/protobuf/stubs/statusor.h @@ -32,7 +32,7 @@ // object. StatusOr models the concept of an object that is either a // usable value, or an error Status explaining why such a value is // not present. To this end, StatusOr does not allow its Status -// value to be Status::OK. Further, StatusOr does not allow the +// value to be Status::kOk. Further, StatusOr does not allow the // contained pointer to be nullptr. // // The primary use-case for StatusOr is as the return value of a @@ -110,8 +110,8 @@ class StatusOr { // value, so it is convenient and sensible to be able to do 'return // Status()' when the return type is StatusOr. // - // REQUIRES: status != Status::OK. This requirement is DCHECKed. - // In optimized builds, passing Status::OK here will have the effect + // REQUIRES: status != Status::kOk. This requirement is DCHECKed. + // In optimized builds, passing Status::kOk here will have the effect // of passing PosixErrorSpace::EINVAL as a fallback. StatusOr(const Status& status); // NOLINT @@ -143,7 +143,7 @@ class StatusOr { StatusOr& operator=(const StatusOr& other); // Returns a reference to our status. If this contains a T, then - // returns Status::OK. + // returns Status::kOk. const Status& status() const; // Returns this->status().ok() @@ -196,7 +196,8 @@ inline StatusOr::StatusOr() template inline StatusOr::StatusOr(const Status& status) { if (status.ok()) { - status_ = Status(error::INTERNAL, "Status::OK is not a valid argument."); + status_ = + Status(StatusCode::kInternal, "Status::kOk is not a valid argument."); } else { status_ = status; } @@ -205,7 +206,7 @@ inline StatusOr::StatusOr(const Status& status) { template inline StatusOr::StatusOr(const T& value) { if (internal::StatusOrHelper::Specialize::IsValueNull(value)) { - status_ = Status(error::INTERNAL, "nullptr is not a valid argument."); + status_ = Status(StatusCode::kInternal, "nullptr is not a valid argument."); } else { status_ = Status::OK; value_ = value; diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index d3a98e5589..feb4ab441f 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc @@ -48,7 +48,6 @@ namespace util { namespace converter { using util::Status; -using util::error::Code; namespace { diff --git a/src/google/protobuf/util/internal/json_stream_parser_test.cc b/src/google/protobuf/util/internal/json_stream_parser_test.cc index 21620c2b87..5e25a98d58 100644 --- a/src/google/protobuf/util/internal/json_stream_parser_test.cc +++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc @@ -139,7 +139,7 @@ class JsonStreamParserTest : public ::testing::Test { }) { util::Status result = RunTest(json, split, setup); EXPECT_EQ(util::error::INVALID_ARGUMENT, result.code()); - StringPiece error_message(result.error_message()); + StringPiece error_message(result.message()); EXPECT_EQ(error_prefix, error_message.substr(0, error_prefix.size())); } diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index 472aa411ee..8ad51df28b 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc @@ -60,11 +60,8 @@ namespace google { namespace protobuf { namespace util { -namespace error { -using util::error::Code; -using util::error::INTERNAL; -} // namespace error namespace converter { + using ::PROTOBUF_NAMESPACE_ID::internal::WireFormat; using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite; From de53e1afff299ea67eab77ba33bff304b6007ca7 Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Thu, 4 Mar 2021 19:25:16 +0100 Subject: [PATCH 37/55] Revert moving status.cc --- BUILD | 2 +- cmake/libprotobuf-lite.cmake | 2 +- src/Makefile.am | 2 +- src/google/protobuf/stubs/internal/status.h | 119 ------------------ .../protobuf/stubs/{internal => }/status.cc | 0 src/google/protobuf/stubs/status.h | 78 +++++++++++- 6 files changed, 80 insertions(+), 123 deletions(-) delete mode 100644 src/google/protobuf/stubs/internal/status.h rename src/google/protobuf/stubs/{internal => }/status.cc (100%) diff --git a/BUILD b/BUILD index 9b4b2fbd02..1124321602 100644 --- a/BUILD +++ b/BUILD @@ -183,7 +183,7 @@ cc_library( "src/google/protobuf/stubs/bytestream.cc", "src/google/protobuf/stubs/common.cc", "src/google/protobuf/stubs/int128.cc", - "src/google/protobuf/stubs/internal/status.cc", + "src/google/protobuf/stubs/status.cc", "src/google/protobuf/stubs/statusor.cc", "src/google/protobuf/stubs/stringpiece.cc", "src/google/protobuf/stubs/stringprintf.cc", diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake index bbd3c11cb7..6d325d5dca 100644 --- a/cmake/libprotobuf-lite.cmake +++ b/cmake/libprotobuf-lite.cmake @@ -20,7 +20,7 @@ set(libprotobuf_lite_files ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream.cc ${protobuf_source_dir}/src/google/protobuf/stubs/common.cc ${protobuf_source_dir}/src/google/protobuf/stubs/int128.cc - ${protobuf_source_dir}/src/google/protobuf/stubs/internal/status.cc + ${protobuf_source_dir}/src/google/protobuf/stubs/status.cc ${protobuf_source_dir}/src/google/protobuf/stubs/statusor.cc ${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece.cc ${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf.cc diff --git a/src/Makefile.am b/src/Makefile.am index 207e6c92b1..a59971a94b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -185,7 +185,7 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/io/io_win32.cc \ google/protobuf/stubs/map_util.h \ google/protobuf/stubs/mathutil.h \ - google/protobuf/stubs/internal/status.cc \ + google/protobuf/stubs/status.cc \ google/protobuf/stubs/status.h \ google/protobuf/stubs/status_macros.h \ google/protobuf/stubs/statusor.cc \ diff --git a/src/google/protobuf/stubs/internal/status.h b/src/google/protobuf/stubs/internal/status.h deleted file mode 100644 index 79c1f80795..0000000000 --- a/src/google/protobuf/stubs/internal/status.h +++ /dev/null @@ -1,119 +0,0 @@ -// 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. - -#ifndef GOOGLE_PROTOBUF_STUBS_INTERNAL_STATUS_H_ -#define GOOGLE_PROTOBUF_STUBS_INTERNAL_STATUS_H_ - -#include - -#include - -#include - -namespace google { -namespace protobuf { -namespace util { -namespace status_internal { - -// These values must match error codes defined in google/rpc/code.proto. -enum class StatusCode : int { - kOk = 0, - kCancelled = 1, - kUnknown = 2, - kInvalidArgument = 3, - kDeadlineExceeded = 4, - kNotFound = 5, - kAlreadyExists = 6, - kPermissionDenied = 7, - kUnauthenticated = 16, - kResourceExhausted = 8, - kFailedPrecondition = 9, - kAborted = 10, - kOutOfRange = 11, - kUnimplemented = 12, - kInternal = 13, - kUnavailable = 14, - kDataLoss = 15, -}; - -class PROTOBUF_EXPORT Status { - public: - // Creates a "successful" status. - Status(); - - // Create a status in the canonical error space with the specified - // code, and error message. If "code == 0", error_message is - // ignored and a Status object identical to Status::kOk is - // constructed. - Status(StatusCode error_code, StringPiece error_message); - Status(const Status&); - Status& operator=(const Status& x); - ~Status() {} - - // Some pre-defined Status objects - static const Status OK; // Identical to 0-arg constructor - static const Status CANCELLED; - static const Status UNKNOWN; - - // Accessor - bool ok() const { - return error_code_ == StatusCode::kOk; - } - StatusCode code() const { - return error_code_; - } - StringPiece message() const { - return error_message_; - } - - bool operator==(const Status& x) const; - bool operator!=(const Status& x) const { - return !operator==(x); - } - - // Return a combination of the error code name and message. - std::string ToString() const; - - private: - StatusCode error_code_; - std::string error_message_; -}; - -// Prints a human-readable representation of 'x' to 'os'. -PROTOBUF_EXPORT std::ostream& operator<<(std::ostream& os, const Status& x); - -} // namespace status_internal -} // namespace util -} // namespace protobuf -} // namespace google - -#include - -#endif // GOOGLE_PROTOBUF_STUBS_INTERNAL_STATUS_H_ diff --git a/src/google/protobuf/stubs/internal/status.cc b/src/google/protobuf/stubs/status.cc similarity index 100% rename from src/google/protobuf/stubs/internal/status.cc rename to src/google/protobuf/stubs/status.cc diff --git a/src/google/protobuf/stubs/status.h b/src/google/protobuf/stubs/status.h index 67951abfd6..0eb0b53f93 100644 --- a/src/google/protobuf/stubs/status.h +++ b/src/google/protobuf/stubs/status.h @@ -31,11 +31,85 @@ #ifndef GOOGLE_PROTOBUF_STUBS_STATUS_H_ #define GOOGLE_PROTOBUF_STUBS_STATUS_H_ -#include +#include + +#include + +#include namespace google { namespace protobuf { namespace util { +namespace status_internal { + +// These values must match error codes defined in google/rpc/code.proto. +enum class StatusCode : int { + kOk = 0, + kCancelled = 1, + kUnknown = 2, + kInvalidArgument = 3, + kDeadlineExceeded = 4, + kNotFound = 5, + kAlreadyExists = 6, + kPermissionDenied = 7, + kUnauthenticated = 16, + kResourceExhausted = 8, + kFailedPrecondition = 9, + kAborted = 10, + kOutOfRange = 11, + kUnimplemented = 12, + kInternal = 13, + kUnavailable = 14, + kDataLoss = 15, +}; + +class PROTOBUF_EXPORT Status { + public: + // Creates a "successful" status. + Status(); + + // Create a status in the canonical error space with the specified + // code, and error message. If "code == 0", error_message is + // ignored and a Status object identical to Status::kOk is + // constructed. + Status(StatusCode error_code, StringPiece error_message); + Status(const Status&); + Status& operator=(const Status& x); + ~Status() {} + + // Some pre-defined Status objects + static const Status OK; // Identical to 0-arg constructor + static const Status CANCELLED; + static const Status UNKNOWN; + + // Accessor + bool ok() const { + return error_code_ == StatusCode::kOk; + } + StatusCode code() const { + return error_code_; + } + StringPiece message() const { + return error_message_; + } + + bool operator==(const Status& x) const; + bool operator!=(const Status& x) const { + return !operator==(x); + } + + // Return a combination of the error code name and message. + std::string ToString() const; + + private: + StatusCode error_code_; + std::string error_message_; +}; + +// Prints a human-readable representation of 'x' to 'os'. +PROTOBUF_EXPORT std::ostream& operator<<(std::ostream& os, const Status& x); + +} // namespace status_internal using ::google::protobuf::util::status_internal::Status; using ::google::protobuf::util::status_internal::StatusCode; @@ -55,4 +129,6 @@ constexpr StatusCode INTERNAL = StatusCode::kInternal; } // namespace protobuf } // namespace google +#include + #endif // GOOGLE_PROTOBUF_STUBS_STATUS_H_ From baef01b7566075cf91e437b6322fbf582ec713dc Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Tue, 9 Mar 2021 22:18:43 +0100 Subject: [PATCH 38/55] Fix build error --- src/google/protobuf/util/internal/json_stream_parser_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/protobuf/util/internal/json_stream_parser_test.cc b/src/google/protobuf/util/internal/json_stream_parser_test.cc index 5e25a98d58..9d38a4f618 100644 --- a/src/google/protobuf/util/internal/json_stream_parser_test.cc +++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc @@ -150,7 +150,7 @@ class JsonStreamParserTest : public ::testing::Test { }) { util::Status result = RunTest(json, split, setup); EXPECT_EQ(util::error::INVALID_ARGUMENT, result.code()); - StringPiece error_message(result.error_message()); + StringPiece error_message(result.message()); EXPECT_EQ(error_prefix, error_message.substr(0, error_prefix.size())); } From dedbd63306e4c464b5a58ee9452b388347bd2e06 Mon Sep 17 00:00:00 2001 From: Nikhil Benesch Date: Sun, 25 Feb 2018 17:22:40 -0500 Subject: [PATCH 39/55] Add --fatal_warnings flag to treat warnings as errors Add a --fatal_warnings flag that requests that protoc exit with a failing status code if any warnings are generated during compilation. Partially address #3980. --- .../compiler/command_line_interface.cc | 18 +++++++++-- .../compiler/command_line_interface.h | 3 ++ .../command_line_interface_unittest.cc | 31 +++++++++++++++++-- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 28b0bfa933..7b66f01103 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -288,7 +288,7 @@ class CommandLineInterface::ErrorPrinter public DescriptorPool::ErrorCollector { public: ErrorPrinter(ErrorFormat format, DiskSourceTree* tree = NULL) - : format_(format), tree_(tree), found_errors_(false) {} + : format_(format), tree_(tree), found_errors_(false), found_warnings_(false) {} ~ErrorPrinter() {} // implements MultiFileErrorCollector ------------------------------ @@ -300,6 +300,7 @@ class CommandLineInterface::ErrorPrinter void AddWarning(const std::string& filename, int line, int column, const std::string& message) { + found_warnings_ = true; AddErrorOrWarning(filename, line, column, message, "warning", std::clog); } @@ -327,6 +328,8 @@ class CommandLineInterface::ErrorPrinter bool FoundErrors() const { return found_errors_; } + bool FoundWarnings() const { return found_warnings_; } + private: void AddErrorOrWarning(const std::string& filename, int line, int column, const std::string& message, const std::string& type, @@ -365,6 +368,7 @@ class CommandLineInterface::ErrorPrinter const ErrorFormat format_; DiskSourceTree* tree_; bool found_errors_; + bool found_warnings_; }; // ------------------------------------------------------------------- @@ -1117,7 +1121,8 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { } } - if (error_collector->FoundErrors()) { + if (error_collector->FoundErrors() || + (fatal_warnings_ && error_collector->FoundWarnings())) { return 1; } @@ -1630,7 +1635,8 @@ bool CommandLineInterface::ParseArgument(const char* arg, std::string* name, *name == "--version" || *name == "--decode_raw" || *name == "--print_free_field_numbers" || *name == "--experimental_allow_proto3_optional" || - *name == "--deterministic_output") { + *name == "--deterministic_output" || + *name == "--fatal_warnings") { // HACK: These are the only flags that don't take a value. // They probably should not be hard-coded like this but for now it's // not worth doing better. @@ -1883,6 +1889,12 @@ CommandLineInterface::InterpretArgument(const std::string& name, return PARSE_ARGUMENT_FAIL; } + } else if (name == "--fatal_warnings") { + if (fatal_warnings_) { + std::cerr << name << " may only be passed once." << std::endl; + return PARSE_ARGUMENT_FAIL; + } + fatal_warnings_ = true; } else if (name == "--plugin") { if (plugin_prefix_.empty()) { std::cerr << "This compiler does not support plugins." << std::endl; diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index 4ff2471c76..e2361fffab 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -392,6 +392,9 @@ class PROTOC_EXPORT CommandLineInterface { ErrorFormat error_format_ = ERROR_FORMAT_GCC; + // True if we should treat warnings as errors that fail the compilation. + bool fatal_warnings_; + std::vector > proto_path_; // Search path for proto files. std::vector input_files_; // Names of the input proto files. diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index 74dc9bffdb..a0e79874ad 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -132,6 +132,9 @@ class CommandLineInterfaceTest : public testing::Test { // ----------------------------------------------------------------- // Methods to check the test results (called after Run()). + // Checks that Run() returned code r. + void ExpectReturnCode(int r); + // Checks that no text was written to stderr during Run(), and Run() // returned 0. void ExpectNoErrors(); @@ -406,6 +409,10 @@ void CommandLineInterfaceTest::CreateTempDir(const std::string& name) { // ------------------------------------------------------------------- +void CommandLineInterfaceTest::ExpectReturnCode(int r) { + EXPECT_EQ(r, return_code_); +} + void CommandLineInterfaceTest::ExpectNoErrors() { EXPECT_EQ(0, return_code_); EXPECT_EQ("", error_text_); @@ -2309,12 +2316,32 @@ TEST_F(CommandLineInterfaceTest, InvalidErrorFormat) { "syntax = \"proto2\";\n" "badsyntax\n"); - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir --error_format=invalid foo.proto"); + Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir foo.proto"); ExpectErrorText("Unknown error format: invalid\n"); } +TEST_F(CommandLineInterfaceTest, Warnings) { + // Test --fatal_warnings. + + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n"); + + Run("protocol_compiler --test_out=$tmpdir " + "--proto_path=$tmpdir foo.proto"); + ExpectReturnCode(0); + ExpectErrorSubstringWithZeroReturnCode( + "foo.proto: warning: Import bar.proto but not used."); + + Run("protocol_compiler --test_out=$tmpdir --fatal_warnings " + "--proto_path=$tmpdir foo.proto"); + ExpectErrorSubstring( + "foo.proto: warning: Import bar.proto but not used."); +} + // ------------------------------------------------------------------- // Flag parsing tests From c7a6160a87eea71ac002aefad54c116a108ba010 Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 9 Dec 2020 22:58:37 +0200 Subject: [PATCH 40/55] Fixes to make the --fatal_warnings flag work with current master --- .../compiler/command_line_interface.cc | 4 +++ .../compiler/command_line_interface.h | 2 +- .../command_line_interface_unittest.cc | 33 +++++++++++-------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 7b66f01103..b0b2963d2d 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -2054,6 +2054,10 @@ Parse PROTO_FILES and generate output based on the options given: --error_format=FORMAT Set the format in which to print errors. FORMAT may be 'gcc' (the default) or 'msvs' (Microsoft Visual Studio format). + --fatal_warnings Make warnings be fatal (similar to -Werr in + gcc). This flag will make protoc return + with a non-zero exit code if any warnings + are generated. --print_free_field_numbers Print the free field numbers of the messages defined in the given proto files. Groups share the same field number space with the parent diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index e2361fffab..5fdc04b4ed 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -393,7 +393,7 @@ class PROTOC_EXPORT CommandLineInterface { ErrorFormat error_format_ = ERROR_FORMAT_GCC; // True if we should treat warnings as errors that fail the compilation. - bool fatal_warnings_; + bool fatal_warnings_ = false; std::vector > proto_path_; // Search path for proto files. diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index a0e79874ad..2ca86086af 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -132,9 +132,6 @@ class CommandLineInterfaceTest : public testing::Test { // ----------------------------------------------------------------- // Methods to check the test results (called after Run()). - // Checks that Run() returned code r. - void ExpectReturnCode(int r); - // Checks that no text was written to stderr during Run(), and Run() // returned 0. void ExpectNoErrors(); @@ -160,6 +157,11 @@ class CommandLineInterfaceTest : public testing::Test { void ExpectCapturedStdoutSubstringWithZeroReturnCode( const std::string& expected_substring); + // Checks that Run() returned zero and the stderr contains the given + // substring. + void ExpectCapturedStderrSubstringWithZeroReturnCode( + const std::string& expected_substring); + #if defined(_WIN32) && !defined(__CYGWIN__) // Returns true if ExpectErrorSubstring(expected_substring) would pass, but // does not fail otherwise. @@ -409,10 +411,6 @@ void CommandLineInterfaceTest::CreateTempDir(const std::string& name) { // ------------------------------------------------------------------- -void CommandLineInterfaceTest::ExpectReturnCode(int r) { - EXPECT_EQ(r, return_code_); -} - void CommandLineInterfaceTest::ExpectNoErrors() { EXPECT_EQ(0, return_code_); EXPECT_EQ("", error_text_); @@ -433,8 +431,8 @@ void CommandLineInterfaceTest::ExpectErrorSubstring( void CommandLineInterfaceTest::ExpectWarningSubstring( const std::string& expected_substring) { - EXPECT_EQ(0, return_code_); EXPECT_PRED_FORMAT2(testing::IsSubstring, expected_substring, error_text_); + EXPECT_EQ(0, return_code_); } #if defined(_WIN32) && !defined(__CYGWIN__) @@ -522,6 +520,13 @@ void CommandLineInterfaceTest::ExpectCapturedStdoutSubstringWithZeroReturnCode( captured_stdout_); } +void CommandLineInterfaceTest::ExpectCapturedStderrSubstringWithZeroReturnCode( + const std::string& expected_substring) { + EXPECT_EQ(0, return_code_); + EXPECT_PRED_FORMAT2(testing::IsSubstring, expected_substring, + error_text_); +} + void CommandLineInterfaceTest::ExpectFileContent(const std::string& filename, const std::string& content) { std::string path = temp_directory_ + "/" + filename; @@ -2310,13 +2315,14 @@ TEST_F(CommandLineInterfaceTest, MsvsFormatErrors) { } TEST_F(CommandLineInterfaceTest, InvalidErrorFormat) { - // Test --error_format=msvs + // Test invalid --error_format CreateTempFile("foo.proto", "syntax = \"proto2\";\n" "badsyntax\n"); - Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir foo.proto"); + Run("protocol_compiler --test_out=$tmpdir " + "--proto_path=$tmpdir --error_format=invalid foo.proto"); ExpectErrorText("Unknown error format: invalid\n"); } @@ -2332,14 +2338,13 @@ TEST_F(CommandLineInterfaceTest, Warnings) { Run("protocol_compiler --test_out=$tmpdir " "--proto_path=$tmpdir foo.proto"); - ExpectReturnCode(0); - ExpectErrorSubstringWithZeroReturnCode( - "foo.proto: warning: Import bar.proto but not used."); + ExpectCapturedStderrSubstringWithZeroReturnCode( + "foo.proto:2:1: warning: Import bar.proto is unused."); Run("protocol_compiler --test_out=$tmpdir --fatal_warnings " "--proto_path=$tmpdir foo.proto"); ExpectErrorSubstring( - "foo.proto: warning: Import bar.proto but not used."); + "foo.proto:2:1: warning: Import bar.proto is unused."); } // ------------------------------------------------------------------- From c6bce8c10f31ddc30e089ac5fb483dffbfa9bd7f Mon Sep 17 00:00:00 2001 From: Cody Casterline Date: Tue, 9 Mar 2021 14:07:09 -0800 Subject: [PATCH 41/55] Remove link to unmaintained TypeScript library y3llowcake/protoc-gen-ts is no longer maintained: https://github.com/y3llowcake/protoc-gen-ts/issues/2#issuecomment-758215154 FWIW, neither is this one w/ a similar name: thesayyn/protoc-gen-ts: https://github.com/thesayyn/protoc-gen-ts/issues/31#issuecomment-781681955 --- docs/third_party.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/third_party.md b/docs/third_party.md index 7799e308a7..6b0e2710f0 100644 --- a/docs/third_party.md +++ b/docs/third_party.md @@ -101,7 +101,6 @@ These are projects we know about implementing Protocol Buffers for other program * Solidity: https://github.com/celer-network/pb3-gen-sol * Swift: https://github.com/alexeyxo/protobuf-swift * Swift: https://github.com/apple/swift-protobuf/ -* Typescript: https://github.com/y3llowcake/protoc-gen-ts * Vala: https://launchpad.net/protobuf-vala * Visual Basic: http://code.google.com/p/protobuf-net/ From aa5cb98712222e05594dc40a8009de024991c01d Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Wed, 10 Mar 2021 10:05:31 +0100 Subject: [PATCH 42/55] Fix conformance_cpp --- conformance/conformance_cpp.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conformance/conformance_cpp.cc b/conformance/conformance_cpp.cc index d27612b151..5782789dfd 100644 --- a/conformance/conformance_cpp.cc +++ b/conformance/conformance_cpp.cc @@ -134,7 +134,7 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) { &proto_binary, options); if (!status.ok()) { response->set_parse_error(string("Parse error: ") + - std::string(status.error_message())); + std::string(status.message())); return; } @@ -189,7 +189,7 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) { if (!status.ok()) { response->set_serialize_error( string("Failed to serialize JSON output: ") + - std::string(status.error_message())); + std::string(status.message())); return; } break; From a3aecacc24f0ce0b05106fb7f7ae3ce9a5e5cd91 Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Wed, 10 Mar 2021 10:20:39 +0100 Subject: [PATCH 43/55] [bazel] Remove deprecated way to depend on googletest --- BUILD | 44 +++++++++----------------------------------- WORKSPACE | 12 ------------ 2 files changed, 9 insertions(+), 47 deletions(-) diff --git a/BUILD b/BUILD index 1124321602..07ee629a18 100644 --- a/BUILD +++ b/BUILD @@ -14,38 +14,6 @@ exports_files(["LICENSE"]) # build configuration ################################################################################ -# TODO(yannic): Remove in 3.14.0. -string_flag( - name = "incompatible_use_com_google_googletest", - build_setting_default = "true", - values = ["true", "false"] -) - -config_setting( - name = "use_com_google_googletest", - flag_values = { - "//:incompatible_use_com_google_googletest": "true" - }, -) - -GTEST = select({ - "//:use_com_google_googletest": [ - "@com_google_googletest//:gtest", - ], - "//conditions:default": [ - "//external:gtest", - ], -}) - -GTEST_MAIN = select({ - "//:use_com_google_googletest": [ - "@com_google_googletest//:gtest_main", - ], - "//conditions:default": [ - "//external:gtest_main", - ], -}) - ################################################################################ # ZLIB configuration ################################################################################ @@ -571,6 +539,7 @@ COMMON_TEST_SRCS = [ cc_binary( name = "test_plugin", + testonly = True, srcs = [ # AUTOGEN(test_plugin_srcs) "src/google/protobuf/compiler/mock_code_generator.cc", @@ -580,7 +549,8 @@ cc_binary( deps = [ ":protobuf", ":protoc_lib", - ] + GTEST, + "@com_google_googletest//:gtest", + ], ) cc_test( @@ -592,7 +562,9 @@ cc_test( ], deps = [ ":protobuf_lite", - ] + GTEST_MAIN, + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], ) cc_test( @@ -695,7 +667,9 @@ cc_test( ":cc_test_protos", ":protobuf", ":protoc_lib", - ] + PROTOBUF_DEPS + GTEST_MAIN, + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ] + PROTOBUF_DEPS, ) ################################################################################ diff --git a/WORKSPACE b/WORKSPACE index 5a767a97c0..d9ed7c883f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -29,18 +29,6 @@ bind( actual = "//util/python:python_headers", ) -# TODO(yannic): Remove in 3.14.0. -bind( - name = "gtest", - actual = "@com_google_googletest//:gtest", -) - -# TODO(yannic): Remove in 3.14.0. -bind( - name = "gtest_main", - actual = "@com_google_googletest//:gtest_main", -) - jvm_maven_import_external( name = "guava_maven", artifact = "com.google.guava:guava:18.0", From a4694f9b66698a3cd197cbab7932bffeb0ea2ab1 Mon Sep 17 00:00:00 2001 From: salamani Date: Fri, 5 Mar 2021 00:20:07 -0500 Subject: [PATCH 44/55] correcting arch name for s390x --- kokoro/release/protoc/linux/build.sh | 2 +- protoc-artifacts/README.md | 2 +- protoc-artifacts/build-protoc.sh | 6 +++--- protoc-artifacts/build-zip.sh | 4 ++-- protoc-artifacts/pom.xml | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kokoro/release/protoc/linux/build.sh b/kokoro/release/protoc/linux/build.sh index efc3ee62ca..44a95aab35 100755 --- a/kokoro/release/protoc/linux/build.sh +++ b/kokoro/release/protoc/linux/build.sh @@ -23,7 +23,7 @@ sudo apt install -y g++-powerpc64le-linux-gnu protoc-artifacts/build-protoc.sh linux ppcle_64 protoc sudo apt install -y g++-s390x-linux-gnu -protoc-artifacts/build-protoc.sh linux s390x protoc +protoc-artifacts/build-protoc.sh linux s390_64 protoc # Use docker image to build linux artifacts. DOCKER_IMAGE_NAME=protobuf/protoc_$(sha1sum protoc-artifacts/Dockerfile | cut -f1 -d " ") diff --git a/protoc-artifacts/README.md b/protoc-artifacts/README.md index 2c45fefe78..1706ddc0d8 100644 --- a/protoc-artifacts/README.md +++ b/protoc-artifacts/README.md @@ -123,7 +123,7 @@ target directory layout: protoc.exe + ppcle_64 protoc.exe - + s390x + + s390_64 protoc.exe + osx + x86_64 diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index 7f65d37643..4602842622 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -93,7 +93,7 @@ checkArch () assertEq $format "elf64-x86-64" $LINENO elif [[ "$ARCH" == aarch_64 ]]; then assertEq $format "elf64-little" $LINENO - elif [[ "$ARCH" == s390x ]]; then + elif [[ "$ARCH" == s390_64 ]]; then if [[ $host_machine == s390x ]];then assertEq $format "elf64-s390" $LINENO else @@ -149,7 +149,7 @@ checkDependencies () white_list="linux-gate\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux\.so\.2" elif [[ "$ARCH" == x86_64 ]]; then white_list="linux-vdso\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux-x86-64\.so\.2" - elif [[ "$ARCH" == s390x ]]; then + elif [[ "$ARCH" == s390_64 ]]; then if [[ $host_machine != s390x ]];then dump_cmd='objdump -p '"$1"' | grep NEEDED' fi @@ -226,7 +226,7 @@ elif [[ "$(uname)" == Linux* ]]; then elif [[ "$ARCH" == ppcle_64 ]]; then CXXFLAGS="$CXXFLAGS -m64" CONFIGURE_ARGS="$CONFIGURE_ARGS --host=powerpc64le-linux-gnu" - elif [[ "$ARCH" == s390x ]]; then + elif [[ "$ARCH" == s390_64 ]]; then CXXFLAGS="$CXXFLAGS -m64" CONFIGURE_ARGS="$CONFIGURE_ARGS --host=s390x-linux-gnu" else diff --git a/protoc-artifacts/build-zip.sh b/protoc-artifacts/build-zip.sh index 2a25d3cd7e..7d1923e6e6 100755 --- a/protoc-artifacts/build-zip.sh +++ b/protoc-artifacts/build-zip.sh @@ -21,7 +21,7 @@ included. Each invocation will create 8 zip packages: dist/--linux-x86_64.zip dist/--linux-aarch_64.zip dist/--linux-ppcle_64.zip - dist/--linux-s390x.zip + dist/--linux-s390_64.zip EOF exit 1 fi @@ -38,7 +38,7 @@ declare -a FILE_NAMES=( \ linux-x86_64.zip linux-x86_64.exe \ linux-aarch_64.zip linux-aarch_64.exe \ linux-ppcle_64.zip linux-ppcle_64.exe \ - linux-s390x.zip linux-s390x.exe \ + linux-s390_64.zip linux-s390_64.exe \ ) # List of all well-known types to be included. diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index ba9eaf8ac5..e46c902ad5 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -81,8 +81,8 @@ exe - ${basedir}/target/linux/s390x/protoc.exe - linux-s390x + ${basedir}/target/linux/s390_64/protoc.exe + linux-s390_64 exe From 43aca5761385db72e1e8d04997195a262314378a Mon Sep 17 00:00:00 2001 From: chenzhihui Date: Wed, 10 Mar 2021 22:17:30 +0800 Subject: [PATCH 45/55] Allocate extension 1108 to Kratos API Errors --- docs/options.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/options.md b/docs/options.md index d186a52234..79a085e0be 100644 --- a/docs/options.md +++ b/docs/options.md @@ -272,3 +272,7 @@ with info about your project (name and website) so we can add an entry for you. 1. Coach Client Connect (planned release in March 2021) * Website: https://www.coachclientconnect.com * Extension: 1107 + +1. Kratos API Errors + * Website: https://go-kratos.dev + * Extension: 1108 From addd0615bfbc956ca0b9b7328955d0198218e2e7 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 10 Mar 2021 13:54:04 -0800 Subject: [PATCH 46/55] Register mark objects so Protobuf is compaction friendly This commit removes an unused reference and registers globals with the GC so that they will never die. Ruby is getting a compacting GC, and it means that these references can move. Registering them with `rb_gc_register_mark_object` will ensure the constants don't move and will not be collected. --- ruby/ext/google/protobuf_c/protobuf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ruby/ext/google/protobuf_c/protobuf.c b/ruby/ext/google/protobuf_c/protobuf.c index c27f30aa2d..c9eecee11e 100644 --- a/ruby/ext/google/protobuf_c/protobuf.c +++ b/ruby/ext/google/protobuf_c/protobuf.c @@ -37,7 +37,7 @@ #include "message.h" #include "repeated_field.h" -VALUE cError; +VALUE cParseError; VALUE cTypeError; const upb_fielddef* map_field_key(const upb_fielddef* field) { @@ -368,8 +368,10 @@ void Init_protobuf_c() { Map_register(protobuf); Message_register(protobuf); - cError = rb_const_get(protobuf, rb_intern("Error")); + cParseError = rb_const_get(protobuf, rb_intern("ParseError")); + rb_gc_register_mark_object(cParseError); cTypeError = rb_const_get(protobuf, rb_intern("TypeError")); + rb_gc_register_mark_object(cTypeError); rb_define_singleton_method(protobuf, "discard_unknown", Google_Protobuf_discard_unknown, 1); From 971a5935ed68e07a1e7e309cfcb4c39bfa87be8b Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Wed, 10 Mar 2021 10:21:18 -0800 Subject: [PATCH 47/55] Updated CHANGES.txt and PHP changelog for 3.15.6 --- CHANGES.txt | 5 +++++ php/ext/google/protobuf/package.xml | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8e77f6abeb..e59d44b314 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +2021-03-10 version 3.15.6 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + Ruby + * Fixed bug in string comparison logic (#8386) + 2021-03-04 version 3.15.5 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) Ruby diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 4d322769f7..c00f6fba0a 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -22,8 +22,7 @@ 3-Clause BSD License - New changes in 3.15.5: - * Fixed quadratic memory use in array append (#8379) + No new changes in 3.15.6 From 6aa539bf0195f188ff86efe6fb8bfa2b676cdd46 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Wed, 10 Mar 2021 10:16:40 -0800 Subject: [PATCH 48/55] Update protobuf version --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 23 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- src/Makefile.am | 2 +- src/google/protobuf/any.pb.h | 2 +- src/google/protobuf/api.pb.h | 2 +- src/google/protobuf/compiler/plugin.pb.h | 2 +- src/google/protobuf/descriptor.pb.h | 2 +- src/google/protobuf/duration.pb.h | 2 +- src/google/protobuf/empty.pb.h | 2 +- src/google/protobuf/field_mask.pb.h | 2 +- src/google/protobuf/port_def.inc | 2 +- src/google/protobuf/source_context.pb.h | 2 +- src/google/protobuf/struct.pb.h | 2 +- src/google/protobuf/stubs/common.h | 2 +- src/google/protobuf/timestamp.pb.h | 2 +- src/google/protobuf/type.pb.h | 2 +- src/google/protobuf/wrappers.pb.h | 2 +- 31 files changed, 49 insertions(+), 34 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index e76911cc3f..fbd37b2de4 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Protobuf-C++' - s.version = '3.15.5' + s.version = '3.15.6' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = '3-Clause BSD License' diff --git a/Protobuf.podspec b/Protobuf.podspec index 7864d2c232..b61cafc518 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -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.15.5' + s.version = '3.15.6' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/configure.ac b/configure.ac index cb0fc63459..aa4cf5e749 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # In the SVN trunk, the version should always be the next anticipated release # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.15.5],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.15.6],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 87acdfeefe..c6f019a13c 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.15.5 + 3.15.6 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index f7cf3cfd17..8daafb7c77 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.15.5 + 3.15.6 7.2 Google Inc. diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 33aa28195f..af2d7025ab 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.15.5 + 3.15.6 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index ffcbfe3862..4df7d434df 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.5 + 3.15.6 protobuf-java diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 6a011d7708..021eac0ac4 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.5 + 3.15.6 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index 654f9a4329..f6b18838c4 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.5 + 3.15.6 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 1c004eeaf5..37d7c0fb85 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.15.5 + 3.15.6 protobuf-java-util diff --git a/js/package.json b/js/package.json index 0d9266252e..59710469a4 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.15.5", + "version": "3.15.6", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index c00f6fba0a..48e403bf72 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ protobuf-opensource@google.com yes - 2021-03-04 - + 2021-03-10 + - 3.15.5 - 3.15.5 + 3.15.6 + 3.15.6 stable @@ -872,5 +872,20 @@ G A release. + + + 3.15.6 + 3.15.6 + + + stable + stable + + 2021-03-10 + + 3-Clause BSD License + + + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 104a0d6ff7..1a2069bfbb 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -76,7 +76,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -#define PHP_PROTOBUF_VERSION "3.15.5" +#define PHP_PROTOBUF_VERSION "3.15.6" // ptr -> PHP object cache. This is a weak map that caches lazily-created // wrapper objects around upb types: diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index ba9eaf8ac5..12d48bb727 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.15.5 + 3.15.6 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 8c49968e59..b356d67dbb 100644 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,4 +30,4 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.15.5' +__version__ = '3.15.6' diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 7149cf4b2d..0602bab4e7 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.15.5" + s.version = "3.15.6" git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" diff --git a/src/Makefile.am b/src/Makefile.am index a59971a94b..662710aaae 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 26:5:0 +PROTOBUF_VERSION = 26:6:0 if GCC # Turn on all warnings except for sign comparison (we ignore sign comparison diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 76406e6b05..394beb807a 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 42634c6cb9..46c80021a2 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 026619f67e..993f4a253c 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 4bfe37e05a..8166ce07f0 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index e87e7b6d1c..a247a95492 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 9703b50028..8f3a06c091 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 99fc7237e3..9f1b7a58f8 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 42a7a66c81..68efe60b37 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -335,7 +335,7 @@ // Shared google3/opensource definitions. ////////////////////////////////////// -#define PROTOBUF_VERSION 3015005 +#define PROTOBUF_VERSION 3015006 #define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3015000 #define PROTOBUF_MIN_PROTOC_VERSION 3015000 #define PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 4a553e4d77..7683f1f776 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 0758c9cb92..1f1370454f 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 7b380f21ff..2dfcc9b6af 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -82,7 +82,7 @@ namespace internal { // The current version, represented as a single integer to make comparison // easier: major * 10^6 + minor * 10^3 + micro -#define GOOGLE_PROTOBUF_VERSION 3015005 +#define GOOGLE_PROTOBUF_VERSION 3015006 // A suffix string for alpha, beta or rc releases. Empty for stable releases. #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 325b33dcce..3ac35d75cc 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 4cff1f48dc..d1b8e21569 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 65831786f8..b07aa93e62 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3015005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3015006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. From c5abd97e365d6a99216dbd0ca7c120ad85a6053e Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Tue, 21 Jul 2020 19:38:33 +0200 Subject: [PATCH 49/55] [bazel] Add BUILD files for benchmark protos This change adds BUILD files to //benchmarks that allow users to consume the .proto files in that directory to run benchmarks (e.g. for custom generators). --- benchmarks/BUILD | 53 +++++++++++++++++++ benchmarks/datasets/BUILD | 51 ++++++++++++++++++ .../datasets/google_message1/proto2/BUILD | 44 +++++++++++++++ .../datasets/google_message1/proto3/BUILD | 44 +++++++++++++++ benchmarks/datasets/google_message2/BUILD | 44 +++++++++++++++ benchmarks/datasets/google_message3/BUILD | 50 +++++++++++++++++ benchmarks/datasets/google_message4/BUILD | 45 ++++++++++++++++ 7 files changed, 331 insertions(+) create mode 100644 benchmarks/BUILD create mode 100644 benchmarks/datasets/BUILD create mode 100644 benchmarks/datasets/google_message1/proto2/BUILD create mode 100644 benchmarks/datasets/google_message1/proto3/BUILD create mode 100644 benchmarks/datasets/google_message2/BUILD create mode 100644 benchmarks/datasets/google_message3/BUILD create mode 100644 benchmarks/datasets/google_message4/BUILD diff --git a/benchmarks/BUILD b/benchmarks/BUILD new file mode 100644 index 0000000000..0ac35c3b78 --- /dev/null +++ b/benchmarks/BUILD @@ -0,0 +1,53 @@ +load("@rules_cc//cc:defs.bzl", "cc_proto_library") +load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_proto//proto:defs.bzl", "proto_library") + +proto_library( + name = "benchmarks_proto", + srcs = [ + "benchmarks.proto", + ], + strip_import_prefix = "/benchmarks", + visibility = ["//visibility:public"], +) + +cc_proto_library( + name = "benchmarks_cc_proto", + visibility = ["//visibility:public"], + deps = [ + "benchmarks_proto", + ], +) + +java_proto_library( + name = "benchmarks_java_proto", + visibility = ["//visibility:public"], + deps = [ + "benchmarks_proto", + ], +) + +proto_library( + name = "google_size_proto", + srcs = [ + "google_size.proto", + ], + strip_import_prefix = "/benchmarks", + visibility = ["//visibility:public"], +) + +cc_proto_library( + name = "google_size_cc_proto", + visibility = ["//visibility:public"], + deps = [ + "google_size_proto", + ], +) + +java_proto_library( + name = "google_size_java_proto", + visibility = ["//visibility:public"], + deps = [ + "google_size_proto", + ], +) diff --git a/benchmarks/datasets/BUILD b/benchmarks/datasets/BUILD new file mode 100644 index 0000000000..c34e303b62 --- /dev/null +++ b/benchmarks/datasets/BUILD @@ -0,0 +1,51 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_java//java:defs.bzl", "java_library") +load("@rules_proto//proto:defs.bzl", "proto_library") + +filegroup( + name = "datasets", + srcs = [ + "//benchmarks/datasets/google_message1/proto2:datasets", + "//benchmarks/datasets/google_message1/proto3:datasets", + "//benchmarks/datasets/google_message2:datasets", + "//benchmarks/datasets/google_message3:datasets", + "//benchmarks/datasets/google_message4:datasets", + ], + visibility = ["//visibility:public"], +) + +proto_library( + name = "protos", + visibility = ["//visibility:public"], + deps = [ + "//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_proto", + "//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_proto", + "//benchmarks/datasets/google_message2:benchmark_message2_proto", + "//benchmarks/datasets/google_message3:benchmark_message3_proto", + "//benchmarks/datasets/google_message4:benchmark_message4_proto", + ], +) + +cc_library( + name = "cc_protos", + visibility = ["//visibility:public"], + deps = [ + "//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_cc_proto", + "//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_cc_proto", + "//benchmarks/datasets/google_message2:benchmark_message2_cc_proto", + "//benchmarks/datasets/google_message3:benchmark_message3_cc_proto", + "//benchmarks/datasets/google_message4:benchmark_message4_cc_proto", + ], +) + +java_library( + name = "java_protos", + visibility = ["//visibility:public"], + exports = [ + "//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_java_proto", + "//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_java_proto", + "//benchmarks/datasets/google_message2:benchmark_message2_java_proto", + "//benchmarks/datasets/google_message3:benchmark_message3_java_proto", + "//benchmarks/datasets/google_message4:benchmark_message4_java_proto", + ], +) diff --git a/benchmarks/datasets/google_message1/proto2/BUILD b/benchmarks/datasets/google_message1/proto2/BUILD new file mode 100644 index 0000000000..d4d38cec22 --- /dev/null +++ b/benchmarks/datasets/google_message1/proto2/BUILD @@ -0,0 +1,44 @@ +load("@rules_cc//cc:defs.bzl", "cc_proto_library") +load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_proto//proto:defs.bzl", "proto_library") + +filegroup( + name = "datasets", + srcs = [ + "dataset.google_message1_proto2.pb", + ], + visibility = [ + "//benchmarks/datasets:__pkg__", + ], +) + +proto_library( + name = "benchmark_message1_proto2_proto", + srcs = [ + "benchmark_message1_proto2.proto", + ], + strip_import_prefix = "/benchmarks", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], +) + +cc_proto_library( + name = "benchmark_message1_proto2_cc_proto", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], + deps = [ + "benchmark_message1_proto2_proto", + ], +) + +java_proto_library( + name = "benchmark_message1_proto2_java_proto", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], + deps = [ + "benchmark_message1_proto2_proto", + ], +) diff --git a/benchmarks/datasets/google_message1/proto3/BUILD b/benchmarks/datasets/google_message1/proto3/BUILD new file mode 100644 index 0000000000..c2d627acd8 --- /dev/null +++ b/benchmarks/datasets/google_message1/proto3/BUILD @@ -0,0 +1,44 @@ +load("@rules_cc//cc:defs.bzl", "cc_proto_library") +load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_proto//proto:defs.bzl", "proto_library") + +filegroup( + name = "datasets", + srcs = [ + "dataset.google_message1_proto3.pb", + ], + visibility = [ + "//benchmarks/datasets:__pkg__", + ], +) + +proto_library( + name = "benchmark_message1_proto3_proto", + srcs = [ + "benchmark_message1_proto3.proto", + ], + strip_import_prefix = "/benchmarks", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], +) + +cc_proto_library( + name = "benchmark_message1_proto3_cc_proto", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], + deps = [ + "benchmark_message1_proto3_proto", + ], +) + +java_proto_library( + name = "benchmark_message1_proto3_java_proto", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], + deps = [ + "benchmark_message1_proto3_proto", + ], +) diff --git a/benchmarks/datasets/google_message2/BUILD b/benchmarks/datasets/google_message2/BUILD new file mode 100644 index 0000000000..1ca87fb64f --- /dev/null +++ b/benchmarks/datasets/google_message2/BUILD @@ -0,0 +1,44 @@ +load("@rules_cc//cc:defs.bzl", "cc_proto_library") +load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_proto//proto:defs.bzl", "proto_library") + +filegroup( + name = "datasets", + srcs = [ + "dataset.google_message2.pb", + ], + visibility = [ + "//benchmarks/datasets:__pkg__", + ], +) + +proto_library( + name = "benchmark_message2_proto", + srcs = [ + "benchmark_message2.proto", + ], + strip_import_prefix = "/benchmarks", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], +) + +cc_proto_library( + name = "benchmark_message2_cc_proto", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], + deps = [ + "benchmark_message2_proto", + ], +) + +java_proto_library( + name = "benchmark_message2_java_proto", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], + deps = [ + "benchmark_message2_proto", + ], +) diff --git a/benchmarks/datasets/google_message3/BUILD b/benchmarks/datasets/google_message3/BUILD new file mode 100644 index 0000000000..9a00294464 --- /dev/null +++ b/benchmarks/datasets/google_message3/BUILD @@ -0,0 +1,50 @@ +load("@rules_cc//cc:defs.bzl", "cc_proto_library") +load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_proto//proto:defs.bzl", "proto_library") + +filegroup( + name = "datasets", + srcs = [], + visibility = [ + "//benchmarks/datasets:__pkg__", + ], +) + +proto_library( + name = "benchmark_message3_proto", + srcs = [ + "benchmark_message3.proto", + "benchmark_message3_1.proto", + "benchmark_message3_2.proto", + "benchmark_message3_3.proto", + "benchmark_message3_4.proto", + "benchmark_message3_5.proto", + "benchmark_message3_6.proto", + "benchmark_message3_7.proto", + "benchmark_message3_8.proto", + ], + strip_import_prefix = "/benchmarks", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], +) + +cc_proto_library( + name = "benchmark_message3_cc_proto", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], + deps = [ + "benchmark_message3_proto", + ], +) + +java_proto_library( + name = "benchmark_message3_java_proto", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], + deps = [ + "benchmark_message3_proto", + ], +) diff --git a/benchmarks/datasets/google_message4/BUILD b/benchmarks/datasets/google_message4/BUILD new file mode 100644 index 0000000000..b23a4c955c --- /dev/null +++ b/benchmarks/datasets/google_message4/BUILD @@ -0,0 +1,45 @@ +load("@rules_cc//cc:defs.bzl", "cc_proto_library") +load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_proto//proto:defs.bzl", "proto_library") + +filegroup( + name = "datasets", + srcs = [], + visibility = [ + "//benchmarks/datasets:__pkg__", + ], +) + +proto_library( + name = "benchmark_message4_proto", + srcs = [ + "benchmark_message4.proto", + "benchmark_message4_1.proto", + "benchmark_message4_2.proto", + "benchmark_message4_3.proto", + ], + strip_import_prefix = "/benchmarks", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], +) + +cc_proto_library( + name = "benchmark_message4_cc_proto", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], + deps = [ + "benchmark_message4_proto", + ], +) + +java_proto_library( + name = "benchmark_message4_java_proto", + visibility = [ + "//benchmarks/datasets:__pkg__", + ], + deps = [ + "benchmark_message4_proto", + ], +) From ef70abad8acfc70983585c0d0bb4049bf38dc62e Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Sun, 14 Mar 2021 10:58:03 +0100 Subject: [PATCH 50/55] Restrict visibility and add target for C++ benchmark --- WORKSPACE | 9 +++++++++ benchmarks/BUILD | 24 ++++++++++++++++++------ benchmarks/cpp/BUILD | 15 +++++++++++++++ benchmarks/datasets/BUILD | 16 ++++++++++++---- 4 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 benchmarks/cpp/BUILD diff --git a/WORKSPACE b/WORKSPACE index d9ed7c883f..4346dbd906 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -17,6 +17,15 @@ http_archive( ], ) +http_archive( + name = "com_github_google_benchmark", + sha256 = "2a778d821997df7d8646c9c59b8edb9a573a6e04c534c01892a40aa524a7b68c", + strip_prefix = "benchmark-bf585a2789e30585b4e3ce6baf11ef2750b54677", + urls = [ + "https://github.com/google/benchmark/archive/bf585a2789e30585b4e3ce6baf11ef2750b54677.zip", + ], +) + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("//:protobuf_deps.bzl", "protobuf_deps") diff --git a/benchmarks/BUILD b/benchmarks/BUILD index 0ac35c3b78..8e6063ba83 100644 --- a/benchmarks/BUILD +++ b/benchmarks/BUILD @@ -8,12 +8,16 @@ proto_library( "benchmarks.proto", ], strip_import_prefix = "/benchmarks", - visibility = ["//visibility:public"], + visibility = [ + "//benchmarks:__subpackages__", + ], ) cc_proto_library( name = "benchmarks_cc_proto", - visibility = ["//visibility:public"], + visibility = [ + "//benchmarks:__subpackages__", + ], deps = [ "benchmarks_proto", ], @@ -21,7 +25,9 @@ cc_proto_library( java_proto_library( name = "benchmarks_java_proto", - visibility = ["//visibility:public"], + visibility = [ + "//benchmarks:__subpackages__", + ], deps = [ "benchmarks_proto", ], @@ -33,12 +39,16 @@ proto_library( "google_size.proto", ], strip_import_prefix = "/benchmarks", - visibility = ["//visibility:public"], + visibility = [ + "//benchmarks:__subpackages__", + ], ) cc_proto_library( name = "google_size_cc_proto", - visibility = ["//visibility:public"], + visibility = [ + "//benchmarks:__subpackages__", + ], deps = [ "google_size_proto", ], @@ -46,7 +56,9 @@ cc_proto_library( java_proto_library( name = "google_size_java_proto", - visibility = ["//visibility:public"], + visibility = [ + "//benchmarks:__subpackages__", + ], deps = [ "google_size_proto", ], diff --git a/benchmarks/cpp/BUILD b/benchmarks/cpp/BUILD new file mode 100644 index 0000000000..b744f896ad --- /dev/null +++ b/benchmarks/cpp/BUILD @@ -0,0 +1,15 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "cpp", + srcs = [ + "cpp_benchmark.cc", + ], + tags = ["benchmark"], + deps = [ + "//:protobuf", + "//benchmarks:benchmarks_cc_proto", + "//benchmarks/datasets:cc_protos", + "@com_github_google_benchmark//:benchmark_main", + ], +) diff --git a/benchmarks/datasets/BUILD b/benchmarks/datasets/BUILD index c34e303b62..f29a27650b 100644 --- a/benchmarks/datasets/BUILD +++ b/benchmarks/datasets/BUILD @@ -11,12 +11,16 @@ filegroup( "//benchmarks/datasets/google_message3:datasets", "//benchmarks/datasets/google_message4:datasets", ], - visibility = ["//visibility:public"], + visibility = [ + "//benchmarks:__subpackages__", + ], ) proto_library( name = "protos", - visibility = ["//visibility:public"], + visibility = [ + "//benchmarks:__subpackages__", + ], deps = [ "//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_proto", "//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_proto", @@ -28,7 +32,9 @@ proto_library( cc_library( name = "cc_protos", - visibility = ["//visibility:public"], + visibility = [ + "//benchmarks:__subpackages__", + ], deps = [ "//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_cc_proto", "//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_cc_proto", @@ -40,7 +46,9 @@ cc_library( java_library( name = "java_protos", - visibility = ["//visibility:public"], + visibility = [ + "//benchmarks:__subpackages__", + ], exports = [ "//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_java_proto", "//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_java_proto", From 3a7bd9c236fda465c16b90567f6b8706915da6cb Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Sun, 14 Mar 2021 13:47:33 +0100 Subject: [PATCH 51/55] Make util::Status more similar to absl::Status Progress on #3688 --- src/google/protobuf/stubs/status.cc | 136 +++++++++++- src/google/protobuf/stubs/status.h | 96 +++++++-- src/google/protobuf/stubs/status_test.cc | 200 +++++++++++++++--- src/google/protobuf/stubs/statusor.h | 22 +- src/google/protobuf/stubs/statusor_test.cc | 36 ++-- .../protobuf/util/internal/datapiece.cc | 26 +-- .../util/internal/field_mask_utility.cc | 18 +- .../util/internal/json_stream_parser.cc | 34 ++- .../util/internal/json_stream_parser.h | 2 +- .../util/internal/json_stream_parser_test.cc | 4 +- .../protobuf/util/internal/proto_writer.cc | 5 +- .../util/internal/protostream_objectsource.cc | 43 ++-- .../util/internal/protostream_objectsource.h | 2 +- .../internal/protostream_objectsource_test.cc | 16 +- .../util/internal/protostream_objectwriter.cc | 50 ++--- src/google/protobuf/util/json_util.cc | 18 +- src/google/protobuf/util/json_util_test.cc | 3 +- .../protobuf/util/type_resolver_util.cc | 14 +- 18 files changed, 512 insertions(+), 213 deletions(-) diff --git a/src/google/protobuf/stubs/status.cc b/src/google/protobuf/stubs/status.cc index 731e1084e1..e0718521a4 100644 --- a/src/google/protobuf/stubs/status.cc +++ b/src/google/protobuf/stubs/status.cc @@ -85,10 +85,6 @@ inline std::string StatusCodeToString(StatusCode code) { } // namespace -const Status Status::OK = Status(); -const Status Status::CANCELLED = Status(StatusCode::kCancelled, ""); -const Status Status::UNKNOWN = Status(StatusCode::kUnknown, ""); - Status::Status() : error_code_(StatusCode::kOk) { } @@ -127,11 +123,143 @@ std::string Status::ToString() const { } } +Status OkStatus() { + return Status(); +} + std::ostream& operator<<(std::ostream& os, const Status& x) { os << x.ToString(); return os; } +bool IsAborted(const Status& status) { + return status.code() == StatusCode::kAborted; +} + +bool IsAlreadyExists(const Status& status) { + return status.code() == StatusCode::kAlreadyExists; +} + +bool IsCancelled(const Status& status) { + return status.code() == StatusCode::kCancelled; +} + +bool IsDataLoss(const Status& status) { + return status.code() == StatusCode::kDataLoss; +} + +bool IsDeadlineExceeded(const Status& status) { + return status.code() == StatusCode::kDeadlineExceeded; +} + +bool IsFailedPrecondition(const Status& status) { + return status.code() == StatusCode::kFailedPrecondition; +} + +bool IsInternal(const Status& status) { + return status.code() == StatusCode::kInternal; +} + +bool IsInvalidArgument(const Status& status) { + return status.code() == StatusCode::kInvalidArgument; +} + +bool IsNotFound(const Status& status) { + return status.code() == StatusCode::kNotFound; +} + +bool IsOutOfRange(const Status& status) { + return status.code() == StatusCode::kOutOfRange; +} + +bool IsPermissionDenied(const Status& status) { + return status.code() == StatusCode::kPermissionDenied; +} + +bool IsResourceExhausted(const Status& status) { + return status.code() == StatusCode::kResourceExhausted; +} + +bool IsUnauthenticated(const Status& status) { + return status.code() == StatusCode::kUnauthenticated; +} + +bool IsUnavailable(const Status& status) { + return status.code() == StatusCode::kUnavailable; +} + +bool IsUnimplemented(const Status& status) { + return status.code() == StatusCode::kUnimplemented; +} + +bool IsUnknown(const Status& status) { + return status.code() == StatusCode::kUnknown; +} + +Status AbortedError(StringPiece message) { + return Status(StatusCode::kAborted, message); +} + +Status AlreadyExistsError(StringPiece message) { + return Status(StatusCode::kAlreadyExists, message); +} + +Status CancelledError(StringPiece message) { + return Status(StatusCode::kCancelled, message); +} + +Status DataLossError(StringPiece message) { + return Status(StatusCode::kDataLoss, message); +} + +Status DeadlineExceededError(StringPiece message) { + return Status(StatusCode::kDeadlineExceeded, message); +} + +Status FailedPreconditionError(StringPiece message) { + return Status(StatusCode::kFailedPrecondition, message); +} + +Status InternalError(StringPiece message) { + return Status(StatusCode::kInternal, message); +} + +Status InvalidArgumentError(StringPiece message) { + return Status(StatusCode::kInvalidArgument, message); +} + +Status NotFoundError(StringPiece message) { + return Status(StatusCode::kNotFound, message); +} + +Status OutOfRangeError(StringPiece message) { + return Status(StatusCode::kOutOfRange, message); +} + +Status PermissionDeniedError(StringPiece message) { + return Status(StatusCode::kPermissionDenied, message); +} + +Status ResourceExhaustedError(StringPiece message) { + return Status(StatusCode::kResourceExhausted, message); +} + +Status UnauthenticatedError(StringPiece message) { + return Status(StatusCode::kUnauthenticated, message); +} + +Status UnavailableError(StringPiece message) { + return Status(StatusCode::kUnavailable, message); +} + +Status UnimplementedError(StringPiece message) { + return Status(StatusCode::kUnimplemented, message); +} + +Status UnknownError(StringPiece message) { + return Status(StatusCode::kUnknown, message); +} + } // namespace status_internal } // namespace util } // namespace protobuf diff --git a/src/google/protobuf/stubs/status.h b/src/google/protobuf/stubs/status.h index 0eb0b53f93..187bc27078 100644 --- a/src/google/protobuf/stubs/status.h +++ b/src/google/protobuf/stubs/status.h @@ -77,11 +77,6 @@ class PROTOBUF_EXPORT Status { Status& operator=(const Status& x); ~Status() {} - // Some pre-defined Status objects - static const Status OK; // Identical to 0-arg constructor - static const Status CANCELLED; - static const Status UNKNOWN; - // Accessor bool ok() const { return error_code_ == StatusCode::kOk; @@ -106,25 +101,96 @@ class PROTOBUF_EXPORT Status { std::string error_message_; }; +// Returns an OK status, equivalent to a default constructed instance. Prefer +// usage of `OkStatus()` when constructing such an OK status. +PROTOBUF_EXPORT Status OkStatus(); + // Prints a human-readable representation of 'x' to 'os'. PROTOBUF_EXPORT std::ostream& operator<<(std::ostream& os, const Status& x); +// These convenience functions return `true` if a given status matches the +// `StatusCode` error code of its associated function. +PROTOBUF_EXPORT bool IsAborted(const Status& status); +PROTOBUF_EXPORT bool IsAlreadyExists(const Status& status); +PROTOBUF_EXPORT bool IsCancelled(const Status& status); +PROTOBUF_EXPORT bool IsDataLoss(const Status& status); +PROTOBUF_EXPORT bool IsDeadlineExceeded(const Status& status); +PROTOBUF_EXPORT bool IsFailedPrecondition(const Status& status); +PROTOBUF_EXPORT bool IsInternal(const Status& status); +PROTOBUF_EXPORT bool IsInvalidArgument(const Status& status); +PROTOBUF_EXPORT bool IsNotFound(const Status& status); +PROTOBUF_EXPORT bool IsOutOfRange(const Status& status); +PROTOBUF_EXPORT bool IsPermissionDenied(const Status& status); +PROTOBUF_EXPORT bool IsResourceExhausted(const Status& status); +PROTOBUF_EXPORT bool IsUnauthenticated(const Status& status); +PROTOBUF_EXPORT bool IsUnavailable(const Status& status); +PROTOBUF_EXPORT bool IsUnimplemented(const Status& status); +PROTOBUF_EXPORT bool IsUnknown(const Status& status); + +// These convenience functions create an `Status` object with an error code as +// indicated by the associated function name, using the error message passed in +// `message`. +// +// These functions are intentionally named `*Error` rather than `*Status` to +// match the names from Abseil: +// https://github.com/abseil/abseil-cpp/blob/2e9532cc6c701a8323d0cffb468999ab804095ab/absl/status/status.h#L716 +PROTOBUF_EXPORT Status AbortedError(StringPiece message); +PROTOBUF_EXPORT Status AlreadyExistsError(StringPiece message); +PROTOBUF_EXPORT Status CancelledError(StringPiece message); +PROTOBUF_EXPORT Status DataLossError(StringPiece message); +PROTOBUF_EXPORT Status DeadlineExceededError(StringPiece message); +PROTOBUF_EXPORT Status FailedPreconditionError(StringPiece message); +PROTOBUF_EXPORT Status InternalError(StringPiece message); +PROTOBUF_EXPORT Status InvalidArgumentError(StringPiece message); +PROTOBUF_EXPORT Status NotFoundError(StringPiece message); +PROTOBUF_EXPORT Status OutOfRangeError(StringPiece message); +PROTOBUF_EXPORT Status PermissionDeniedError(StringPiece message); +PROTOBUF_EXPORT Status ResourceExhaustedError(StringPiece message); +PROTOBUF_EXPORT Status UnauthenticatedError(StringPiece message); +PROTOBUF_EXPORT Status UnavailableError(StringPiece message); +PROTOBUF_EXPORT Status UnimplementedError(StringPiece message); +PROTOBUF_EXPORT Status UnknownError(StringPiece message); + } // namespace status_internal using ::google::protobuf::util::status_internal::Status; using ::google::protobuf::util::status_internal::StatusCode; -namespace error { - -// TODO(yannic): Remove these. -constexpr StatusCode OK = StatusCode::kOk; -constexpr StatusCode CANCELLED = StatusCode::kCancelled; -constexpr StatusCode UNKNOWN = StatusCode::kUnknown; -constexpr StatusCode INVALID_ARGUMENT = StatusCode::kInvalidArgument; -constexpr StatusCode NOT_FOUND = StatusCode::kNotFound; -constexpr StatusCode INTERNAL = StatusCode::kInternal; +using ::google::protobuf::util::status_internal::IsAborted; +using ::google::protobuf::util::status_internal::IsAlreadyExists; +using ::google::protobuf::util::status_internal::IsCancelled; +using ::google::protobuf::util::status_internal::IsDataLoss; +using ::google::protobuf::util::status_internal::IsDeadlineExceeded; +using ::google::protobuf::util::status_internal::IsFailedPrecondition; +using ::google::protobuf::util::status_internal::IsInternal; +using ::google::protobuf::util::status_internal::IsInvalidArgument; +using ::google::protobuf::util::status_internal::IsNotFound; +using ::google::protobuf::util::status_internal::IsOutOfRange; +using ::google::protobuf::util::status_internal::IsPermissionDenied; +using ::google::protobuf::util::status_internal::IsResourceExhausted; +using ::google::protobuf::util::status_internal::IsUnauthenticated; +using ::google::protobuf::util::status_internal::IsUnavailable; +using ::google::protobuf::util::status_internal::IsUnimplemented; +using ::google::protobuf::util::status_internal::IsUnknown; + +using ::google::protobuf::util::status_internal::OkStatus; +using ::google::protobuf::util::status_internal::AbortedError; +using ::google::protobuf::util::status_internal::AlreadyExistsError; +using ::google::protobuf::util::status_internal::CancelledError; +using ::google::protobuf::util::status_internal::DataLossError; +using ::google::protobuf::util::status_internal::DeadlineExceededError; +using ::google::protobuf::util::status_internal::FailedPreconditionError; +using ::google::protobuf::util::status_internal::InternalError; +using ::google::protobuf::util::status_internal::InvalidArgumentError; +using ::google::protobuf::util::status_internal::NotFoundError; +using ::google::protobuf::util::status_internal::OutOfRangeError; +using ::google::protobuf::util::status_internal::PermissionDeniedError; +using ::google::protobuf::util::status_internal::ResourceExhaustedError; +using ::google::protobuf::util::status_internal::UnauthenticatedError; +using ::google::protobuf::util::status_internal::UnavailableError; +using ::google::protobuf::util::status_internal::UnimplementedError; +using ::google::protobuf::util::status_internal::UnknownError; -} // namespace error } // namespace util } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/status_test.cc b/src/google/protobuf/stubs/status_test.cc index ce486809db..cca6c2bc3d 100644 --- a/src/google/protobuf/stubs/status_test.cc +++ b/src/google/protobuf/stubs/status_test.cc @@ -37,22 +37,170 @@ namespace google { namespace protobuf { namespace { -TEST(Status, Empty) { - util::Status status; - EXPECT_EQ(util::error::OK, util::Status::OK.code()); - EXPECT_EQ("OK", util::Status::OK.ToString()); -} -TEST(Status, GenericCodes) { - EXPECT_EQ(util::error::OK, util::Status::OK.code()); - EXPECT_EQ(util::error::CANCELLED, util::Status::CANCELLED.code()); - EXPECT_EQ(util::error::UNKNOWN, util::Status::UNKNOWN.code()); +TEST(Status, Constructor) { + EXPECT_EQ(util::StatusCode::kOk, + util::Status(util::StatusCode::kOk, "").code()); + EXPECT_EQ(util::StatusCode::kCancelled, + util::Status(util::StatusCode::kCancelled, "").code()); + EXPECT_EQ(util::StatusCode::kUnknown, + util::Status(util::StatusCode::kUnknown, "").code()); + EXPECT_EQ(util::StatusCode::kInvalidArgument, + util::Status(util::StatusCode::kInvalidArgument, "").code()); + EXPECT_EQ(util::StatusCode::kDeadlineExceeded, + util::Status(util::StatusCode::kDeadlineExceeded, "").code()); + EXPECT_EQ(util::StatusCode::kNotFound, + util::Status(util::StatusCode::kNotFound, "").code()); + EXPECT_EQ(util::StatusCode::kAlreadyExists, + util::Status(util::StatusCode::kAlreadyExists, "").code()); + EXPECT_EQ(util::StatusCode::kPermissionDenied, + util::Status(util::StatusCode::kPermissionDenied, "").code()); + EXPECT_EQ(util::StatusCode::kUnauthenticated, + util::Status(util::StatusCode::kUnauthenticated, "").code()); + EXPECT_EQ(util::StatusCode::kResourceExhausted, + util::Status(util::StatusCode::kResourceExhausted, "").code()); + EXPECT_EQ(util::StatusCode::kFailedPrecondition, + util::Status(util::StatusCode::kFailedPrecondition, "").code()); + EXPECT_EQ(util::StatusCode::kAborted, + util::Status(util::StatusCode::kAborted, "").code()); + EXPECT_EQ(util::StatusCode::kOutOfRange, + util::Status(util::StatusCode::kOutOfRange, "").code()); + EXPECT_EQ(util::StatusCode::kUnimplemented, + util::Status(util::StatusCode::kUnimplemented, "").code()); + EXPECT_EQ(util::StatusCode::kInternal, + util::Status(util::StatusCode::kInternal, "").code()); + EXPECT_EQ(util::StatusCode::kUnavailable, + util::Status(util::StatusCode::kUnavailable, "").code()); + EXPECT_EQ(util::StatusCode::kDataLoss, + util::Status(util::StatusCode::kDataLoss, "").code()); } TEST(Status, ConstructorZero) { - util::Status status(util::error::OK, "msg"); + util::Status status(util::StatusCode::kOk, "msg"); EXPECT_TRUE(status.ok()); EXPECT_EQ("OK", status.ToString()); + EXPECT_EQ(util::OkStatus(), status); +} + +TEST(Status, ConvenienceConstructors) { + EXPECT_EQ(util::StatusCode::kOk, util::OkStatus().code()); + EXPECT_EQ("", util::OkStatus().message()); + + EXPECT_EQ(util::StatusCode::kCancelled, util::CancelledError("").code()); + EXPECT_EQ("", util::CancelledError("").message()); + EXPECT_EQ("foo", util::CancelledError("foo").message()); + EXPECT_EQ("bar", util::CancelledError("bar").message()); + + EXPECT_EQ(util::StatusCode::kUnknown, util::UnknownError("").code()); + EXPECT_EQ("", util::UnknownError("").message()); + EXPECT_EQ("foo", util::UnknownError("foo").message()); + EXPECT_EQ("bar", util::UnknownError("bar").message()); + + EXPECT_EQ(util::StatusCode::kInvalidArgument, + util::InvalidArgumentError("").code()); + EXPECT_EQ("", util::InvalidArgumentError("").message()); + EXPECT_EQ("foo", util::InvalidArgumentError("foo").message()); + EXPECT_EQ("bar", util::InvalidArgumentError("bar").message()); + + EXPECT_EQ(util::StatusCode::kDeadlineExceeded, + util::DeadlineExceededError("").code()); + EXPECT_EQ("", util::DeadlineExceededError("").message()); + EXPECT_EQ("foo", util::DeadlineExceededError("foo").message()); + EXPECT_EQ("bar", util::DeadlineExceededError("bar").message()); + + EXPECT_EQ(util::StatusCode::kNotFound, util::NotFoundError("").code()); + EXPECT_EQ("", util::NotFoundError("").message()); + EXPECT_EQ("foo", util::NotFoundError("foo").message()); + EXPECT_EQ("bar", util::NotFoundError("bar").message()); + + EXPECT_EQ(util::StatusCode::kAlreadyExists, + util::AlreadyExistsError("").code()); + EXPECT_EQ("", util::AlreadyExistsError("").message()); + EXPECT_EQ("foo", util::AlreadyExistsError("foo").message()); + EXPECT_EQ("bar", util::AlreadyExistsError("bar").message()); + + EXPECT_EQ(util::StatusCode::kPermissionDenied, + util::PermissionDeniedError("").code()); + EXPECT_EQ("", util::PermissionDeniedError("").message()); + EXPECT_EQ("foo", util::PermissionDeniedError("foo").message()); + EXPECT_EQ("bar", util::PermissionDeniedError("bar").message()); + + EXPECT_EQ(util::StatusCode::kUnauthenticated, + util::UnauthenticatedError("").code()); + EXPECT_EQ("", util::UnauthenticatedError("").message()); + EXPECT_EQ("foo", util::UnauthenticatedError("foo").message()); + EXPECT_EQ("bar", util::UnauthenticatedError("bar").message()); + + EXPECT_EQ(util::StatusCode::kResourceExhausted, + util::ResourceExhaustedError("").code()); + EXPECT_EQ("", util::ResourceExhaustedError("").message()); + EXPECT_EQ("foo", util::ResourceExhaustedError("foo").message()); + EXPECT_EQ("bar", util::ResourceExhaustedError("bar").message()); + + EXPECT_EQ(util::StatusCode::kFailedPrecondition, + util::FailedPreconditionError("").code()); + EXPECT_EQ("", util::FailedPreconditionError("").message()); + EXPECT_EQ("foo", util::FailedPreconditionError("foo").message()); + EXPECT_EQ("bar", util::FailedPreconditionError("bar").message()); + + EXPECT_EQ(util::StatusCode::kAborted, util::AbortedError("").code()); + EXPECT_EQ("", util::AbortedError("").message()); + EXPECT_EQ("foo", util::AbortedError("foo").message()); + EXPECT_EQ("bar", util::AbortedError("bar").message()); + + EXPECT_EQ(util::StatusCode::kOutOfRange, util::OutOfRangeError("").code()); + EXPECT_EQ("", util::OutOfRangeError("").message()); + EXPECT_EQ("foo", util::OutOfRangeError("foo").message()); + EXPECT_EQ("bar", util::OutOfRangeError("bar").message()); + + EXPECT_EQ(util::StatusCode::kUnimplemented, + util::UnimplementedError("").code()); + EXPECT_EQ("", util::UnimplementedError("").message()); + EXPECT_EQ("foo", util::UnimplementedError("foo").message()); + EXPECT_EQ("bar", util::UnimplementedError("bar").message()); + + EXPECT_EQ(util::StatusCode::kInternal, util::InternalError("").code()); + EXPECT_EQ("", util::InternalError("").message()); + EXPECT_EQ("foo", util::InternalError("foo").message()); + EXPECT_EQ("bar", util::InternalError("bar").message()); + + EXPECT_EQ(util::StatusCode::kUnavailable, util::UnavailableError("").code()); + EXPECT_EQ("", util::UnavailableError("").message()); + EXPECT_EQ("foo", util::UnavailableError("foo").message()); + EXPECT_EQ("bar", util::UnavailableError("bar").message()); + + EXPECT_EQ(util::StatusCode::kDataLoss, util::DataLossError("").code()); + EXPECT_EQ("", util::DataLossError("").message()); + EXPECT_EQ("foo", util::DataLossError("foo").message()); + EXPECT_EQ("bar", util::DataLossError("bar").message()); +} + +TEST(Status, ConvenienceTests) { + EXPECT_TRUE(util::OkStatus().ok()); + EXPECT_TRUE(util::IsCancelled(util::CancelledError(""))); + EXPECT_TRUE(util::IsUnknown(util::UnknownError(""))); + EXPECT_TRUE(util::IsInvalidArgument(util::InvalidArgumentError(""))); + EXPECT_TRUE(util::IsDeadlineExceeded(util::DeadlineExceededError(""))); + EXPECT_TRUE(util::IsNotFound(util::NotFoundError(""))); + EXPECT_TRUE(util::IsAlreadyExists(util::AlreadyExistsError(""))); + EXPECT_TRUE(util::IsPermissionDenied(util::PermissionDeniedError(""))); + EXPECT_TRUE(util::IsUnauthenticated(util::UnauthenticatedError(""))); + EXPECT_TRUE(util::IsResourceExhausted(util::ResourceExhaustedError(""))); + EXPECT_TRUE(util::IsFailedPrecondition(util::FailedPreconditionError(""))); + EXPECT_TRUE(util::IsAborted(util::AbortedError(""))); + EXPECT_TRUE(util::IsOutOfRange(util::OutOfRangeError(""))); + EXPECT_TRUE(util::IsUnimplemented(util::UnimplementedError(""))); + EXPECT_TRUE(util::IsInternal(util::InternalError(""))); + EXPECT_TRUE(util::IsUnavailable(util::UnavailableError(""))); + EXPECT_TRUE(util::IsDataLoss(util::DataLossError(""))); +} + +TEST(Status, Empty) { + util::Status status; + EXPECT_TRUE(status.ok()); + EXPECT_EQ(util::OkStatus(), status); + EXPECT_EQ(util::StatusCode::kOk, status.code()); + EXPECT_EQ("OK", status.ToString()); } TEST(Status, CheckOK) { @@ -63,38 +211,35 @@ TEST(Status, CheckOK) { } TEST(Status, ErrorMessage) { - util::Status status(util::error::INVALID_ARGUMENT, ""); + util::Status status = util::InvalidArgumentError(""); EXPECT_FALSE(status.ok()); EXPECT_EQ("", status.message().ToString()); - EXPECT_EQ("", status.message().ToString()); EXPECT_EQ("INVALID_ARGUMENT", status.ToString()); - status = util::Status(util::error::INVALID_ARGUMENT, "msg"); + status = util::InvalidArgumentError("msg"); EXPECT_FALSE(status.ok()); EXPECT_EQ("msg", status.message().ToString()); - EXPECT_EQ("msg", status.message().ToString()); EXPECT_EQ("INVALID_ARGUMENT:msg", status.ToString()); - status = util::Status(util::error::OK, "msg"); + status = util::Status(util::StatusCode::kOk, "msg"); EXPECT_TRUE(status.ok()); EXPECT_EQ("", status.message().ToString()); - EXPECT_EQ("", status.message().ToString()); EXPECT_EQ("OK", status.ToString()); } TEST(Status, Copy) { - util::Status a(util::error::UNKNOWN, "message"); + util::Status a = util::UnknownError("message"); util::Status b(a); ASSERT_EQ(a.ToString(), b.ToString()); } TEST(Status, Assign) { - util::Status a(util::error::UNKNOWN, "message"); + util::Status a = util::UnknownError("message"); util::Status b; b = a; ASSERT_EQ(a.ToString(), b.ToString()); } TEST(Status, AssignEmpty) { - util::Status a(util::error::UNKNOWN, "message"); + util::Status a = util::UnknownError("message"); util::Status b; a = b; ASSERT_EQ(std::string("OK"), a.ToString()); @@ -103,32 +248,33 @@ TEST(Status, AssignEmpty) { } TEST(Status, EqualsOK) { - ASSERT_EQ(util::Status::OK, util::Status()); + ASSERT_EQ(util::OkStatus(), util::Status()); } TEST(Status, EqualsSame) { - const util::Status a = util::Status(util::error::CANCELLED, "message"); - const util::Status b = util::Status(util::error::CANCELLED, "message"); + const util::Status a = util::CancelledError("message"); + const util::Status b = util::CancelledError("message"); ASSERT_EQ(a, b); } TEST(Status, EqualsCopy) { - const util::Status a = util::Status(util::error::CANCELLED, "message"); + const util::Status a = util::CancelledError("message"); const util::Status b = a; ASSERT_EQ(a, b); } TEST(Status, EqualsDifferentCode) { - const util::Status a = util::Status(util::error::CANCELLED, "message"); - const util::Status b = util::Status(util::error::UNKNOWN, "message"); + const util::Status a = util::CancelledError("message"); + const util::Status b = util::UnknownError("message"); ASSERT_NE(a, b); } TEST(Status, EqualsDifferentMessage) { - const util::Status a = util::Status(util::error::CANCELLED, "message"); - const util::Status b = util::Status(util::error::CANCELLED, "another"); + const util::Status a = util::CancelledError("message"); + const util::Status b = util::CancelledError("another"); ASSERT_NE(a, b); } + } // namespace } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/statusor.h b/src/google/protobuf/stubs/statusor.h index c3748eacc1..6d8aea5909 100644 --- a/src/google/protobuf/stubs/statusor.h +++ b/src/google/protobuf/stubs/statusor.h @@ -32,7 +32,7 @@ // object. StatusOr models the concept of an object that is either a // usable value, or an error Status explaining why such a value is // not present. To this end, StatusOr does not allow its Status -// value to be Status::kOk. Further, StatusOr does not allow the +// value to be OkStatus(). Further, StatusOr does not allow the // contained pointer to be nullptr. // // The primary use-case for StatusOr is as the return value of a @@ -72,8 +72,7 @@ // // StatusOr FooFactory::MakeNewFoo(int arg) { // if (arg <= 0) { -// return ::util::Status(::util::error::INVALID_ARGUMENT, -// "Arg must be positive"); +// return InvalidArgumentError("Arg must be positive"); // } else { // return new Foo(arg); // } @@ -100,7 +99,7 @@ class StatusOr { template friend class StatusOr; public: - // Construct a new StatusOr with Status::UNKNOWN status + // Construct a new StatusOr with UnknownError() status. StatusOr(); // Construct a new StatusOr with the given non-ok status. After calling @@ -110,8 +109,8 @@ class StatusOr { // value, so it is convenient and sensible to be able to do 'return // Status()' when the return type is StatusOr. // - // REQUIRES: status != Status::kOk. This requirement is DCHECKed. - // In optimized builds, passing Status::kOk here will have the effect + // REQUIRES: status != OkStatus(). This requirement is DCHECKed. + // In optimized builds, passing OkStatus() here will have the effect // of passing PosixErrorSpace::EINVAL as a fallback. StatusOr(const Status& status); // NOLINT @@ -143,7 +142,7 @@ class StatusOr { StatusOr& operator=(const StatusOr& other); // Returns a reference to our status. If this contains a T, then - // returns Status::kOk. + // returns OkStatus(). const Status& status() const; // Returns this->status().ok() @@ -190,14 +189,13 @@ struct StatusOrHelper::Specialize { template inline StatusOr::StatusOr() - : status_(util::Status::UNKNOWN) { + : status_(util::UnknownError("")) { } template inline StatusOr::StatusOr(const Status& status) { if (status.ok()) { - status_ = - Status(StatusCode::kInternal, "Status::kOk is not a valid argument."); + status_ = util::InternalError("OkStatus() is not a valid argument."); } else { status_ = status; } @@ -206,9 +204,9 @@ inline StatusOr::StatusOr(const Status& status) { template inline StatusOr::StatusOr(const T& value) { if (internal::StatusOrHelper::Specialize::IsValueNull(value)) { - status_ = Status(StatusCode::kInternal, "nullptr is not a valid argument."); + status_ = util::InternalError("nullptr is not a valid argument."); } else { - status_ = Status::OK; + status_ = util::OkStatus(); value_ = value; } } diff --git a/src/google/protobuf/stubs/statusor_test.cc b/src/google/protobuf/stubs/statusor_test.cc index 6e2a9e5545..683900c6c3 100644 --- a/src/google/protobuf/stubs/statusor_test.cc +++ b/src/google/protobuf/stubs/statusor_test.cc @@ -71,13 +71,13 @@ class CopyNoAssign { TEST(StatusOr, TestDefaultCtor) { StatusOr thing; EXPECT_FALSE(thing.ok()); - EXPECT_EQ(Status::UNKNOWN, thing.status()); + EXPECT_EQ(util::UnknownError(""), thing.status()); } TEST(StatusOr, TestStatusCtor) { - StatusOr thing(Status::CANCELLED); + StatusOr thing(util::CancelledError("")); EXPECT_FALSE(thing.ok()); - EXPECT_EQ(Status::CANCELLED, thing.status()); + EXPECT_EQ(util::CancelledError(""), thing.status()); } TEST(StatusOr, TestValueCtor) { @@ -96,7 +96,7 @@ TEST(StatusOr, TestCopyCtorStatusOk) { } TEST(StatusOr, TestCopyCtorStatusNotOk) { - StatusOr original(Status::CANCELLED); + StatusOr original(util::CancelledError("")); StatusOr copy(original); EXPECT_EQ(original.status(), copy.status()); } @@ -110,7 +110,7 @@ TEST(StatusOr, TestCopyCtorStatusOKConverting) { } TEST(StatusOr, TestCopyCtorStatusNotOkConverting) { - StatusOr original(Status::CANCELLED); + StatusOr original(util::CancelledError("")); StatusOr copy(original); EXPECT_EQ(original.status(), copy.status()); } @@ -125,7 +125,7 @@ TEST(StatusOr, TestAssignmentStatusOk) { } TEST(StatusOr, TestAssignmentStatusNotOk) { - StatusOr source(Status::CANCELLED); + StatusOr source(util::CancelledError("")); StatusOr target; target = source; EXPECT_EQ(source.status(), target.status()); @@ -141,7 +141,7 @@ TEST(StatusOr, TestAssignmentStatusOKConverting) { } TEST(StatusOr, TestAssignmentStatusNotOkConverting) { - StatusOr source(Status::CANCELLED); + StatusOr source(util::CancelledError("")); StatusOr target; target = source; EXPECT_EQ(source.status(), target.status()); @@ -150,9 +150,9 @@ TEST(StatusOr, TestAssignmentStatusNotOkConverting) { TEST(StatusOr, TestStatus) { StatusOr good(4); EXPECT_TRUE(good.ok()); - StatusOr bad(Status::CANCELLED); + StatusOr bad(util::CancelledError("")); EXPECT_FALSE(bad.ok()); - EXPECT_EQ(Status::CANCELLED, bad.status()); + EXPECT_EQ(util::CancelledError(""), bad.status()); } TEST(StatusOr, TestValue) { @@ -170,13 +170,13 @@ TEST(StatusOr, TestValueConst) { TEST(StatusOr, TestPointerDefaultCtor) { StatusOr thing; EXPECT_FALSE(thing.ok()); - EXPECT_EQ(Status::UNKNOWN, thing.status()); + EXPECT_EQ(util::UnknownError(""), thing.status()); } TEST(StatusOr, TestPointerStatusCtor) { - StatusOr thing(Status::CANCELLED); + StatusOr thing(util::CancelledError("")); EXPECT_FALSE(thing.ok()); - EXPECT_EQ(Status::CANCELLED, thing.status()); + EXPECT_EQ(util::CancelledError(""), thing.status()); } TEST(StatusOr, TestPointerValueCtor) { @@ -195,7 +195,7 @@ TEST(StatusOr, TestPointerCopyCtorStatusOk) { } TEST(StatusOr, TestPointerCopyCtorStatusNotOk) { - StatusOr original(Status::CANCELLED); + StatusOr original(util::CancelledError("")); StatusOr copy(original); EXPECT_EQ(original.status(), copy.status()); } @@ -210,7 +210,7 @@ TEST(StatusOr, TestPointerCopyCtorStatusOKConverting) { } TEST(StatusOr, TestPointerCopyCtorStatusNotOkConverting) { - StatusOr original(Status::CANCELLED); + StatusOr original(util::CancelledError("")); StatusOr copy(original); EXPECT_EQ(original.status(), copy.status()); } @@ -225,7 +225,7 @@ TEST(StatusOr, TestPointerAssignmentStatusOk) { } TEST(StatusOr, TestPointerAssignmentStatusNotOk) { - StatusOr source(Status::CANCELLED); + StatusOr source(util::CancelledError("")); StatusOr target; target = source; EXPECT_EQ(source.status(), target.status()); @@ -242,7 +242,7 @@ TEST(StatusOr, TestPointerAssignmentStatusOKConverting) { } TEST(StatusOr, TestPointerAssignmentStatusNotOkConverting) { - StatusOr source(Status::CANCELLED); + StatusOr source(util::CancelledError("")); StatusOr target; target = source; EXPECT_EQ(source.status(), target.status()); @@ -252,8 +252,8 @@ TEST(StatusOr, TestPointerStatus) { const int kI = 0; StatusOr good(&kI); EXPECT_TRUE(good.ok()); - StatusOr bad(Status::CANCELLED); - EXPECT_EQ(Status::CANCELLED, bad.status()); + StatusOr bad(util::CancelledError("")); + EXPECT_EQ(util::CancelledError(""), bad.status()); } TEST(StatusOr, TestPointerValue) { diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index feb4ab441f..4384b79c24 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc @@ -51,17 +51,13 @@ using util::Status; namespace { -inline Status InvalidArgument(StringPiece value_str) { - return Status(util::error::INVALID_ARGUMENT, value_str); -} - template util::StatusOr ValidateNumberConversion(To after, From before) { if (after == before && MathUtil::Sign(before) == MathUtil::Sign(after)) { return after; } else { - return InvalidArgument(std::is_integral::value + return util::InvalidArgumentError(std::is_integral::value ? ValueAsString(before) : std::is_same::value ? DoubleAsString(before) @@ -106,7 +102,7 @@ util::StatusOr DoubleToFloat(double before) { } else if (before > std::numeric_limits::max() || before < -std::numeric_limits::max()) { // Double value outside of the range of float. - return InvalidArgument(DoubleAsString(before)); + return util::InvalidArgumentError(DoubleAsString(before)); } else { return static_cast(before); } @@ -178,7 +174,7 @@ util::StatusOr DataPiece::ToDouble() const { if (value.ok() && !std::isfinite(value.value())) { // safe_strtod converts out-of-range values to +inf/-inf, but we want // to report them as errors. - return InvalidArgument(StrCat("\"", str_, "\"")); + return util::InvalidArgumentError(StrCat("\"", str_, "\"")); } else { return value; } @@ -208,7 +204,7 @@ util::StatusOr DataPiece::ToBool() const { case TYPE_STRING: return StringToNumber(safe_strtob); default: - return InvalidArgument( + return util::InvalidArgumentError( ValueAsStringOrDefault("Wrong type. Cannot convert to Bool.")); } } @@ -223,7 +219,7 @@ util::StatusOr DataPiece::ToString() const { return base64; } default: - return InvalidArgument( + return util::InvalidArgumentError( ValueAsStringOrDefault("Cannot convert to string.")); } } @@ -264,11 +260,11 @@ util::StatusOr DataPiece::ToBytes() const { if (type_ == TYPE_STRING) { std::string decoded; if (!DecodeBase64(str_, &decoded)) { - return InvalidArgument(ValueAsStringOrDefault("Invalid data in input.")); + return util::InvalidArgumentError(ValueAsStringOrDefault("Invalid data in input.")); } return decoded; } else { - return InvalidArgument(ValueAsStringOrDefault( + return util::InvalidArgumentError(ValueAsStringOrDefault( "Wrong type. Only String or Bytes can be converted to Bytes.")); } } @@ -328,7 +324,7 @@ util::StatusOr DataPiece::ToEnum(const google::protobuf::Enum* enum_type, // enum because we preserve unknown enum values as well. return ToInt32(); } - return InvalidArgument( + return util::InvalidArgumentError( ValueAsStringOrDefault("Cannot find enum with given value.")); } @@ -348,7 +344,7 @@ util::StatusOr DataPiece::GenericConvert() const { case TYPE_FLOAT: return NumberConvertAndCheck(float_); default: // TYPE_ENUM, TYPE_STRING, TYPE_CORD, TYPE_BOOL - return InvalidArgument(ValueAsStringOrDefault( + return util::InvalidArgumentError(ValueAsStringOrDefault( "Wrong type. Bool, Enum, String and Cord not supported in " "GenericConvert.")); } @@ -358,11 +354,11 @@ template util::StatusOr DataPiece::StringToNumber(bool (*func)(StringPiece, To*)) const { if (str_.size() > 0 && (str_[0] == ' ' || str_[str_.size() - 1] == ' ')) { - return InvalidArgument(StrCat("\"", str_, "\"")); + return util::InvalidArgumentError(StrCat("\"", str_, "\"")); } To result; if (func(str_, &result)) return result; - return InvalidArgument(StrCat("\"", std::string(str_), "\"")); + return util::InvalidArgumentError(StrCat("\"", std::string(str_), "\"")); } bool DataPiece::DecodeBase64(StringPiece src, std::string* dest) const { diff --git a/src/google/protobuf/util/internal/field_mask_utility.cc b/src/google/protobuf/util/internal/field_mask_utility.cc index 0beff996a6..cd194e87d4 100644 --- a/src/google/protobuf/util/internal/field_mask_utility.cc +++ b/src/google/protobuf/util/internal/field_mask_utility.cc @@ -134,8 +134,7 @@ util::Status DecodeCompactFieldMaskPaths(StringPiece paths, } // Un-escaped '"' must be followed with a ']'. if (i >= length - 1 || paths[i + 1] != ']') { - return util::Status( - util::error::INVALID_ARGUMENT, + return util::InvalidArgumentError( StrCat( "Invalid FieldMask '", paths, "'. Map keys should be represented as [\"some_key\"].")); @@ -147,8 +146,7 @@ util::Status DecodeCompactFieldMaskPaths(StringPiece paths, // Checks whether the key ends at the end of a path segment. if (i < length - 1 && paths[i + 1] != '.' && paths[i + 1] != ',' && paths[i + 1] != ')' && paths[i + 1] != '(') { - return util::Status( - util::error::INVALID_ARGUMENT, + return util::InvalidArgumentError( StrCat( "Invalid FieldMask '", paths, "'. Map keys should be at the end of a path segment.")); @@ -160,8 +158,7 @@ util::Status DecodeCompactFieldMaskPaths(StringPiece paths, // We are not in a map key, look for the start of one. if (paths[i] == '[') { if (i >= length - 1 || paths[i + 1] != '\"') { - return util::Status( - util::error::INVALID_ARGUMENT, + return util::InvalidArgumentError( StrCat( "Invalid FieldMask '", paths, "'. Map keys should be represented as [\"some_key\"].")); @@ -197,8 +194,7 @@ util::Status DecodeCompactFieldMaskPaths(StringPiece paths, // Removes the last prefix after seeing a ')'. if (i < length && paths[i] == ')') { if (prefix.empty()) { - return util::Status( - util::error::INVALID_ARGUMENT, + return util::InvalidArgumentError( StrCat("Invalid FieldMask '", paths, "'. Cannot find matching '(' for all ')'.")); } @@ -207,14 +203,12 @@ util::Status DecodeCompactFieldMaskPaths(StringPiece paths, previous_position = i + 1; } if (in_map_key) { - return util::Status( - util::error::INVALID_ARGUMENT, + return util::InvalidArgumentError( StrCat("Invalid FieldMask '", paths, "'. Cannot find matching ']' for all '['.")); } if (!prefix.empty()) { - return util::Status( - util::error::INVALID_ARGUMENT, + return util::InvalidArgumentError( StrCat("Invalid FieldMask '", paths, "'. Cannot find matching ')' for all '('.")); } diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index dc0bacad03..f38b68a1d2 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.cc +++ b/src/google/protobuf/util/internal/json_stream_parser.cc @@ -302,14 +302,12 @@ util::Status JsonStreamParser::RunParser() { break; default: - result = util::Status(util::error::INTERNAL, - StrCat("Unknown parse type: ", type)); + result = util::InternalError(StrCat("Unknown parse type: ", type)); break; } if (!result.ok()) { // If we were cancelled, save our state and try again later. - if (!finishing_ && - result == util::Status(util::error::CANCELLED, "")) { + if (!finishing_ && util::IsCancelled(result)) { stack_.push(type); // If we have a key we still need to render, make sure to save off the // contents in our own storage. @@ -353,7 +351,7 @@ util::Status JsonStreamParser::ParseValue(TokenType type) { // don't know if the next char would be e, completing it, or something // else, making it invalid. if (!finishing_ && p_.length() < kKeywordFalse.length()) { - return util::Status(util::error::CANCELLED, ""); + return util::CancelledError(""); } return ReportFailure("Unexpected token.", ParseErrorType::UNEXPECTED_TOKEN); @@ -392,7 +390,7 @@ util::Status JsonStreamParser::ParseStringHelper() { // depending on if we expect more data later. if (p_.length() == 1) { if (!finishing_) { - return util::Status(util::error::CANCELLED, ""); + return util::CancelledError(""); } return ReportFailure("Closing quote expected in string.", ParseErrorType::EXPECTED_CLOSING_QUOTE); @@ -461,7 +459,7 @@ util::Status JsonStreamParser::ParseStringHelper() { } // If we didn't find the closing quote but we expect more data, cancel for now if (!finishing_) { - return util::Status(util::error::CANCELLED, ""); + return util::CancelledError(""); } // End of string reached without a closing quote, report an error. string_open_ = 0; @@ -479,7 +477,7 @@ util::Status JsonStreamParser::ParseStringHelper() { util::Status JsonStreamParser::ParseUnicodeEscape() { if (p_.length() < kUnicodeEscapedLength) { if (!finishing_) { - return util::Status(util::error::CANCELLED, ""); + return util::CancelledError(""); } return ReportFailure("Illegal hex string.", ParseErrorType::ILLEGAL_HEX_STRING); @@ -498,7 +496,7 @@ util::Status JsonStreamParser::ParseUnicodeEscape() { code <= JsonEscaping::kMaxHighSurrogate) { if (p_.length() < 2 * kUnicodeEscapedLength) { if (!finishing_) { - return util::Status(util::error::CANCELLED, ""); + return util::CancelledError(""); } if (!coerce_to_utf8_) { return ReportFailure("Missing low surrogate.", @@ -612,7 +610,7 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) { // If the entire input is a valid number, and we may have more content in the // future, we abort for now and resume when we know more. if (index == length && !finishing_) { - return util::Status(util::error::CANCELLED, ""); + return util::CancelledError(""); } // Create a string containing just the number, so we can use safe_strtoX @@ -799,7 +797,7 @@ util::Status JsonStreamParser::ParseArrayValue(TokenType type) { // empty-null array value is relying on this ARRAY_MID token. stack_.push(ARRAY_MID); util::Status result = ParseValue(type); - if (result == util::Status(util::error::CANCELLED, "")) { + if (util::IsCancelled(result)) { // If we were cancelled, pop back off the ARRAY_MID so we don't try to // push it on again when we try over. stack_.pop(); @@ -874,18 +872,15 @@ util::Status JsonStreamParser::ReportFailure(StringPiece message, StringPiece segment(begin, end - begin); std::string location(p_start - begin, ' '); location.push_back('^'); - auto status = - util::Status(util::error::INVALID_ARGUMENT, - StrCat(message, "\n", segment, "\n", location)); - - return status; + return util::InvalidArgumentError( + StrCat(message, "\n", segment, "\n", location)); } util::Status JsonStreamParser::ReportUnknown(StringPiece message, ParseErrorType parse_code) { // If we aren't finishing the parse, cancel parsing and try later. if (!finishing_) { - return util::Status(util::error::CANCELLED, ""); + return util::CancelledError(""); } if (p_.empty()) { return ReportFailure(StrCat("Unexpected end of string. ", message), @@ -897,8 +892,7 @@ util::Status JsonStreamParser::ReportUnknown(StringPiece message, util::Status JsonStreamParser::IncrementRecursionDepth( StringPiece key) const { if (++recursion_depth_ > max_recursion_depth_) { - return util::Status( - util::error::INVALID_ARGUMENT, + return util::InvalidArgumentError( StrCat("Message too deep. Max recursion depth reached for key '", key, "'")); } @@ -940,7 +934,7 @@ util::Status JsonStreamParser::ParseKey() { // we can't know if the key was complete or not. if (!finishing_ && p_.empty()) { p_ = original; - return util::Status(util::error::CANCELLED, ""); + return util::CancelledError(""); } // Since we aren't using the key storage, clear it out. key_storage_.clear(); diff --git a/src/google/protobuf/util/internal/json_stream_parser.h b/src/google/protobuf/util/internal/json_stream_parser.h index 4c93d77fc5..47dfe82f4a 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.h +++ b/src/google/protobuf/util/internal/json_stream_parser.h @@ -244,7 +244,7 @@ class PROTOBUF_EXPORT JsonStreamParser { ParseErrorType parse_code); // Helper function to check recursion depth and increment it. It will return - // Status::OK if the current depth is allowed. Otherwise an error is returned. + // OkStatus() if the current depth is allowed. Otherwise an error is returned. // key is used for error reporting. util::Status IncrementRecursionDepth(StringPiece key) const; diff --git a/src/google/protobuf/util/internal/json_stream_parser_test.cc b/src/google/protobuf/util/internal/json_stream_parser_test.cc index 9d38a4f618..4bb10251ec 100644 --- a/src/google/protobuf/util/internal/json_stream_parser_test.cc +++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc @@ -138,7 +138,7 @@ class JsonStreamParserTest : public ::testing::Test { std::function setup = [](JsonStreamParser* p) { }) { util::Status result = RunTest(json, split, setup); - EXPECT_EQ(util::error::INVALID_ARGUMENT, result.code()); + EXPECT_TRUE(util::IsInvalidArgument(result)); StringPiece error_message(result.message()); EXPECT_EQ(error_prefix, error_message.substr(0, error_prefix.size())); } @@ -149,7 +149,7 @@ class JsonStreamParserTest : public ::testing::Test { std::function setup = [](JsonStreamParser* p) { }) { util::Status result = RunTest(json, split, setup); - EXPECT_EQ(util::error::INVALID_ARGUMENT, result.code()); + EXPECT_TRUE(util::IsInvalidArgument(result)); StringPiece error_message(result.message()); EXPECT_EQ(error_prefix, error_message.substr(0, error_prefix.size())); } diff --git a/src/google/protobuf/util/internal/proto_writer.cc b/src/google/protobuf/util/internal/proto_writer.cc index 8821dbef6b..ff4fe54aaa 100644 --- a/src/google/protobuf/util/internal/proto_writer.cc +++ b/src/google/protobuf/util/internal/proto_writer.cc @@ -55,8 +55,6 @@ namespace converter { using io::CodedOutputStream; using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite; -using util::error::INVALID_ARGUMENT; - ProtoWriter::ProtoWriter(TypeResolver* type_resolver, const google::protobuf::Type& type, @@ -695,8 +693,7 @@ ProtoWriter* ProtoWriter::RenderPrimitiveField( break; } default: // TYPE_GROUP, TYPE_MESSAGE, TYPE_UNKNOWN. - status = util::Status(util::error::INVALID_ARGUMENT, - data.ValueAsStringOrDefault("")); + status = util::InvalidArgumentError(data.ValueAsStringOrDefault("")); } if (!status.ok()) { diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index 8ad51df28b..b98a14cdb0 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc @@ -102,7 +102,7 @@ util::StatusOr MapKeyDefaultValueAsString( case google::protobuf::Field::TYPE_STRING: return std::string(); default: - return util::Status(util::error::INTERNAL, "Invalid map key type."); + return util::InternalError("Invalid map key type."); } } } // namespace @@ -282,8 +282,7 @@ util::StatusOr ProtoStreamObjectSource::RenderMap( if (key_field == nullptr) { // The Type info for this map entry is incorrect. It should always // have a field named "key" and with field number 1. - return util::Status(util::error::INTERNAL, - "Invalid map entry."); + return util::InternalError("Invalid map entry."); } ASSIGN_OR_RETURN(map_key, MapKeyDefaultValueAsString(*key_field)); } @@ -291,7 +290,7 @@ util::StatusOr ProtoStreamObjectSource::RenderMap( } else { // The Type info for this map entry is incorrect. It should contain // exactly two fields with field number 1 and 2. - return util::Status(util::error::INTERNAL, "Invalid map entry."); + return util::InternalError("Invalid map entry."); } } stream_->PopLimit(old_limit); @@ -318,15 +317,12 @@ util::Status ProtoStreamObjectSource::RenderTimestamp( int64_t seconds = p.first; int32_t nanos = p.second; if (seconds > kTimestampMaxSeconds || seconds < kTimestampMinSeconds) { - return util::Status( - util::error::INTERNAL, - StrCat("Timestamp seconds exceeds limit for field: ", - field_name)); + return util::InternalError( + StrCat("Timestamp seconds exceeds limit for field: ", field_name)); } if (nanos < 0 || nanos >= kNanosPerSecond) { - return util::Status( - util::error::INTERNAL, + return util::InternalError( StrCat("Timestamp nanos exceeds limit for field: ", field_name)); } @@ -343,22 +339,19 @@ util::Status ProtoStreamObjectSource::RenderDuration( int64_t seconds = p.first; int32_t nanos = p.second; if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds) { - return util::Status( - util::error::INTERNAL, + return util::InternalError( StrCat("Duration seconds exceeds limit for field: ", field_name)); } if (nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) { - return util::Status( - util::error::INTERNAL, + return util::InternalError( StrCat("Duration nanos exceeds limit for field: ", field_name)); } std::string sign = ""; if (seconds < 0) { if (nanos > 0) { - return util::Status( - util::error::INTERNAL, + return util::InternalError( StrCat("Duration nanos is non-negative, but seconds is " "negative for field: ", field_name)); @@ -611,8 +604,7 @@ util::Status ProtoStreamObjectSource::RenderAny( // If there is a value but no type, we cannot render it, so report an error. if (type_url.empty()) { // TODO(sven): Add an external message once those are ready. - return util::Status(util::error::INTERNAL, - "Invalid Any, the type_url is missing."); + return util::InternalError("Invalid Any, the type_url is missing."); } util::StatusOr resolved_type = @@ -621,8 +613,7 @@ util::Status ProtoStreamObjectSource::RenderAny( if (!resolved_type.ok()) { // Convert into an internal error, since this means the backend gave us // an invalid response (missing or invalid type information). - return util::Status(util::error::INTERNAL, - resolved_type.status().message()); + return util::InternalError(resolved_type.status().message()); } // nested_type cannot be null at this time. const google::protobuf::Type* nested_type = resolved_type.value(); @@ -659,8 +650,7 @@ util::Status ProtoStreamObjectSource::RenderFieldMask( } } if (paths_field_tag != tag) { - return util::Status(util::error::INTERNAL, - "Invalid FieldMask, unexpected field."); + return util::InternalError("Invalid FieldMask, unexpected field."); } std::string str; os->stream_->ReadVarint32(&buffer32); // string size. @@ -744,8 +734,7 @@ util::Status ProtoStreamObjectSource::RenderField( const google::protobuf::Type* type = typeinfo_->GetTypeByTypeUrl(field->type_url()); if (type == nullptr) { - return util::Status( - util::error::INTERNAL, + return util::InternalError( StrCat("Invalid configuration. Could not find the type: ", field->type_url())); } @@ -762,8 +751,7 @@ util::Status ProtoStreamObjectSource::RenderField( --recursion_depth_; if (!stream_->ConsumedEntireMessage()) { - return util::Status( - util::error::INVALID_ARGUMENT, + return util::InvalidArgumentError( "Nested protocol message not parsed in its entirety."); } stream_->PopLimit(old_limit); @@ -1062,8 +1050,7 @@ std::pair ProtoStreamObjectSource::ReadSecondsAndNanos( util::Status ProtoStreamObjectSource::IncrementRecursionDepth( StringPiece type_name, StringPiece field_name) const { if (++recursion_depth_ > max_recursion_depth_) { - return util::Status( - util::error::INVALID_ARGUMENT, + return util::InvalidArgumentError( StrCat("Message too deep. Max recursion depth reached for type '", type_name, "', field '", field_name, "'")); } diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h index 441e4fd162..60eaf4e1d8 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.h +++ b/src/google/protobuf/util/internal/protostream_objectsource.h @@ -287,7 +287,7 @@ class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { const google::protobuf::Type& type) const; // Helper function to check recursion depth and increment it. It will return - // Status::OK if the current depth is allowed. Otherwise an error is returned. + // OkStatus() if the current depth is allowed. Otherwise an error is returned. // type_name and field_name are used for error reporting. util::Status IncrementRecursionDepth(StringPiece type_name, StringPiece field_name) const; diff --git a/src/google/protobuf/util/internal/protostream_objectsource_test.cc b/src/google/protobuf/util/internal/protostream_objectsource_test.cc index 5bd5a91020..6ea8b29fd7 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource_test.cc @@ -597,7 +597,7 @@ TEST_P(ProtostreamObjectSourceTest, CyclicMessageDepthTest) { } util::Status status = ExecuteTest(cyclic, Cyclic::descriptor()); - EXPECT_EQ(util::error::INVALID_ARGUMENT, status.code()); + EXPECT_TRUE(util::IsInvalidArgument(status)); } class ProtostreamObjectSourceMapsTest : public ProtostreamObjectSourceTest { @@ -943,7 +943,7 @@ TEST_P(ProtostreamObjectSourceAnysTest, MissingTypeUrlError) { ow_.StartObject(""); util::Status status = ExecuteTest(out, AnyOut::descriptor()); - EXPECT_EQ(util::error::INTERNAL, status.code()); + EXPECT_TRUE(util::IsInternal(status)); } TEST_P(ProtostreamObjectSourceAnysTest, UnknownTypeServiceError) { @@ -959,7 +959,7 @@ TEST_P(ProtostreamObjectSourceAnysTest, UnknownTypeServiceError) { ow_.StartObject(""); util::Status status = ExecuteTest(out, AnyOut::descriptor()); - EXPECT_EQ(util::error::INTERNAL, status.code()); + EXPECT_TRUE(util::IsInternal(status)); } TEST_P(ProtostreamObjectSourceAnysTest, UnknownTypeError) { @@ -975,7 +975,7 @@ TEST_P(ProtostreamObjectSourceAnysTest, UnknownTypeError) { ow_.StartObject(""); util::Status status = ExecuteTest(out, AnyOut::descriptor()); - EXPECT_EQ(util::error::INTERNAL, status.code()); + EXPECT_TRUE(util::IsInternal(status)); } class ProtostreamObjectSourceStructTest : public ProtostreamObjectSourceTest { @@ -1108,7 +1108,7 @@ TEST_P(ProtostreamObjectSourceTimestampTest, InvalidTimestampBelowMinTest) { ow_.StartObject(""); util::Status status = ExecuteTest(out, TimestampDuration::descriptor()); - EXPECT_EQ(util::error::INTERNAL, status.code()); + EXPECT_TRUE(util::IsInternal(status)); } TEST_P(ProtostreamObjectSourceTimestampTest, InvalidTimestampAboveMaxTest) { @@ -1119,7 +1119,7 @@ TEST_P(ProtostreamObjectSourceTimestampTest, InvalidTimestampAboveMaxTest) { ow_.StartObject(""); util::Status status = ExecuteTest(out, TimestampDuration::descriptor()); - EXPECT_EQ(util::error::INTERNAL, status.code()); + EXPECT_TRUE(util::IsInternal(status)); } TEST_P(ProtostreamObjectSourceTimestampTest, InvalidDurationBelowMinTest) { @@ -1130,7 +1130,7 @@ TEST_P(ProtostreamObjectSourceTimestampTest, InvalidDurationBelowMinTest) { ow_.StartObject(""); util::Status status = ExecuteTest(out, TimestampDuration::descriptor()); - EXPECT_EQ(util::error::INTERNAL, status.code()); + EXPECT_TRUE(util::IsInternal(status)); } TEST_P(ProtostreamObjectSourceTimestampTest, InvalidDurationAboveMaxTest) { @@ -1141,7 +1141,7 @@ TEST_P(ProtostreamObjectSourceTimestampTest, InvalidDurationAboveMaxTest) { ow_.StartObject(""); util::Status status = ExecuteTest(out, TimestampDuration::descriptor()); - EXPECT_EQ(util::error::INTERNAL, status.code()); + EXPECT_TRUE(util::IsInternal(status)); } TEST_P(ProtostreamObjectSourceTimestampTest, TimestampDurationDefaultValue) { diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index 56ca3caed7..772e6985d9 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc @@ -59,7 +59,6 @@ namespace converter { using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite; using std::placeholders::_1; using util::Status; -using util::error::INVALID_ARGUMENT; ProtoStreamObjectWriter::ProtoStreamObjectWriter( @@ -144,14 +143,14 @@ Status GetNanosFromStringPiece(StringPiece s_nanos, // conversion to 'nanos', rather than a double, so that there is no // loss of precision. if (!s_nanos.empty() && !safe_strto32(s_nanos, &i_nanos)) { - return Status(util::error::INVALID_ARGUMENT, parse_failure_message); + return util::InvalidArgumentError(parse_failure_message); } if (i_nanos > kNanosPerSecond || i_nanos < 0) { - return Status(util::error::INVALID_ARGUMENT, exceeded_limit_message); + return util::InvalidArgumentError(exceeded_limit_message); } // s_nanos should only have digits. No whitespace. if (s_nanos.find_first_not_of("0123456789") != StringPiece::npos) { - return Status(util::error::INVALID_ARGUMENT, parse_failure_message); + return util::InvalidArgumentError(parse_failure_message); } if (i_nanos > 0) { @@ -191,8 +190,7 @@ Status GetNanosFromStringPiece(StringPiece s_nanos, conversion = 1; break; default: - return Status(util::error::INVALID_ARGUMENT, - exceeded_limit_message); + return util::InvalidArgumentError(exceeded_limit_message); } *nanos = i_nanos * conversion; } @@ -1013,9 +1011,9 @@ Status ProtoStreamObjectWriter::RenderStructValue(ProtoStreamObjectWriter* ow, break; } default: { - return Status(util::error::INVALID_ARGUMENT, - "Invalid struct data type. Only number, string, boolean or " - "null values are supported."); + return util::InvalidArgumentError( + "Invalid struct data type. Only number, string, boolean or null " + "values are supported."); } } ow->ProtoWriter::RenderDataPiece(struct_field_name, data); @@ -1026,9 +1024,10 @@ Status ProtoStreamObjectWriter::RenderTimestamp(ProtoStreamObjectWriter* ow, const DataPiece& data) { if (data.type() == DataPiece::TYPE_NULL) return Status(); if (data.type() != DataPiece::TYPE_STRING) { - return Status(util::error::INVALID_ARGUMENT, - StrCat("Invalid data type for timestamp, value is ", - data.ValueAsStringOrDefault(""))); + return util::InvalidArgumentError( + StrCat( + "Invalid data type for timestamp, value is ", + data.ValueAsStringOrDefault(""))); } StringPiece value(data.str()); @@ -1037,7 +1036,7 @@ Status ProtoStreamObjectWriter::RenderTimestamp(ProtoStreamObjectWriter* ow, int32 nanos; if (!::google::protobuf::internal::ParseTime(value.ToString(), &seconds, &nanos)) { - return Status(INVALID_ARGUMENT, StrCat("Invalid time format: ", value)); + return util::InvalidArgumentError(StrCat("Invalid time format: ", value)); } @@ -1057,9 +1056,10 @@ Status ProtoStreamObjectWriter::RenderFieldMask(ProtoStreamObjectWriter* ow, const DataPiece& data) { if (data.type() == DataPiece::TYPE_NULL) return Status(); if (data.type() != DataPiece::TYPE_STRING) { - return Status(util::error::INVALID_ARGUMENT, - StrCat("Invalid data type for field mask, value is ", - data.ValueAsStringOrDefault(""))); + return util::InvalidArgumentError( + StrCat( + "Invalid data type for field mask, value is ", + data.ValueAsStringOrDefault(""))); } // TODO(tsun): figure out how to do proto descriptor based snake case @@ -1073,16 +1073,17 @@ Status ProtoStreamObjectWriter::RenderDuration(ProtoStreamObjectWriter* ow, const DataPiece& data) { if (data.type() == DataPiece::TYPE_NULL) return Status(); if (data.type() != DataPiece::TYPE_STRING) { - return Status(util::error::INVALID_ARGUMENT, - StrCat("Invalid data type for duration, value is ", - data.ValueAsStringOrDefault(""))); + return util::InvalidArgumentError( + StrCat( + "Invalid data type for duration, value is ", + data.ValueAsStringOrDefault(""))); } StringPiece value(data.str()); if (!HasSuffixString(value, "s")) { - return Status(util::error::INVALID_ARGUMENT, - "Illegal duration format; duration must end with 's'"); + return util::InvalidArgumentError( + "Illegal duration format; duration must end with 's'"); } value = value.substr(0, value.size() - 1); int sign = 1; @@ -1095,8 +1096,8 @@ Status ProtoStreamObjectWriter::RenderDuration(ProtoStreamObjectWriter* ow, SplitSecondsAndNanos(value, &s_secs, &s_nanos); uint64_t unsigned_seconds; if (!safe_strtou64(s_secs, &unsigned_seconds)) { - return Status(util::error::INVALID_ARGUMENT, - "Invalid duration format, failed to parse seconds"); + return util::InvalidArgumentError( + "Invalid duration format, failed to parse seconds"); } int32_t nanos = 0; @@ -1111,8 +1112,7 @@ Status ProtoStreamObjectWriter::RenderDuration(ProtoStreamObjectWriter* ow, int64_t seconds = sign * unsigned_seconds; if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds || nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) { - return Status(util::error::INVALID_ARGUMENT, - "Duration value exceeds limits"); + return util::InvalidArgumentError("Duration value exceeds limits"); } ow->ProtoWriter::RenderDataPiece("seconds", DataPiece(seconds)); diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc index eb81b65e1a..2e7b78d039 100644 --- a/src/google/protobuf/util/json_util.cc +++ b/src/google/protobuf/util/json_util.cc @@ -140,25 +140,23 @@ class StatusErrorListener : public converter::ErrorListener { if (!loc_string.empty()) { loc_string.append(" "); } - status_ = - util::Status(util::error::INVALID_ARGUMENT, - StrCat(loc_string, unknown_name, ": ", message)); + status_ = util::InvalidArgumentError( + StrCat(loc_string, unknown_name, ": ", message)); } void InvalidValue(const converter::LocationTrackerInterface& loc, StringPiece type_name, StringPiece value) override { - status_ = util::Status( - util::error::INVALID_ARGUMENT, + status_ = util::InvalidArgumentError( StrCat(GetLocString(loc), ": invalid value ", std::string(value), " for type ", std::string(type_name))); } void MissingField(const converter::LocationTrackerInterface& loc, StringPiece missing_name) override { - status_ = util::Status(util::error::INVALID_ARGUMENT, - StrCat(GetLocString(loc), ": missing field ", - std::string(missing_name))); + status_ = util::InvalidArgumentError( + StrCat( + GetLocString(loc), ": missing field ", std::string(missing_name))); } private: @@ -271,8 +269,8 @@ util::Status JsonStringToMessage(StringPiece input, Message* message, util::Status result = JsonToBinaryString(resolver, GetTypeUrl(*message), input, &binary, options); if (result.ok() && !message->ParseFromString(binary)) { - result = util::Status(util::error::INVALID_ARGUMENT, - "JSON transcoder produced invalid protobuf output."); + result = util::InvalidArgumentError( + "JSON transcoder produced invalid protobuf output."); } if (pool != DescriptorPool::generated_pool()) { delete resolver; diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index 9851cc5d7f..3ffe73ef6b 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -632,8 +632,7 @@ TEST_F(JsonUtilTest, TestWrongJsonInput) { delete resolver; EXPECT_FALSE(result_status.ok()); - EXPECT_EQ(result_status.code(), - util::error::INVALID_ARGUMENT); + EXPECT_TRUE(util::IsInvalidArgument(result_status)); } TEST_F(JsonUtilTest, HtmlEscape) { diff --git a/src/google/protobuf/util/type_resolver_util.cc b/src/google/protobuf/util/type_resolver_util.cc index addb33499a..80fe3411d2 100644 --- a/src/google/protobuf/util/type_resolver_util.cc +++ b/src/google/protobuf/util/type_resolver_util.cc @@ -64,9 +64,6 @@ using google::protobuf::Type; using google::protobuf::UInt32Value; using google::protobuf::UInt64Value; -using util::error::INVALID_ARGUMENT; -using util::error::NOT_FOUND; - class DescriptorPoolTypeResolver : public TypeResolver { public: DescriptorPoolTypeResolver(const std::string& url_prefix, @@ -83,8 +80,8 @@ class DescriptorPoolTypeResolver : public TypeResolver { const Descriptor* descriptor = pool_->FindMessageTypeByName(type_name); if (descriptor == NULL) { - return util::Status(util::error::NOT_FOUND, - "Invalid type URL, unknown type: " + type_name); + return util::NotFoundError( + "Invalid type URL, unknown type: " + type_name); } ConvertDescriptor(descriptor, type); return util::Status(); @@ -100,8 +97,8 @@ class DescriptorPoolTypeResolver : public TypeResolver { const EnumDescriptor* descriptor = pool_->FindEnumTypeByName(type_name); if (descriptor == NULL) { - return util::Status(util::error::NOT_FOUND, - "Invalid type URL, unknown type: " + type_name); + return util::InvalidArgumentError( + "Invalid type URL, unknown type: " + type_name); } ConvertEnumDescriptor(descriptor, enum_type); return util::Status(); @@ -309,8 +306,7 @@ class DescriptorPoolTypeResolver : public TypeResolver { util::Status ParseTypeUrl(const std::string& type_url, std::string* type_name) { if (type_url.substr(0, url_prefix_.size() + 1) != url_prefix_ + "/") { - return util::Status( - util::error::INVALID_ARGUMENT, + return util::InvalidArgumentError( StrCat("Invalid type URL, type URLs must be of the form '", url_prefix_, "/', got: ", type_url)); } From b4cddb71d604e52bddd6bf7d2d8311ef11a78dd4 Mon Sep 17 00:00:00 2001 From: Maxim Reznik Date: Tue, 16 Mar 2021 18:44:23 +0200 Subject: [PATCH 52/55] Add protobuf for Ada --- docs/third_party.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/third_party.md b/docs/third_party.md index 6b0e2710f0..9d490c0a6e 100644 --- a/docs/third_party.md +++ b/docs/third_party.md @@ -11,6 +11,7 @@ These are projects we know about implementing Protocol Buffers for other program * Action Script: https://code.google.com/p/protoc-gen-as3/ * Action Script: https://github.com/matrix3d/JProtoc * Action Script: https://github.com/zhongfq/protobuf-as3/ +* Ada: https://github.com/reznikmm/protobuf * C: https://github.com/protobuf-c/protobuf-c * C: http://koti.kapsi.fi/jpa/nanopb/ * C: https://github.com/cloudwu/pbc/ From 57e09ad84867f88792489b459caddb6482476b0d Mon Sep 17 00:00:00 2001 From: Steve Rago Date: Wed, 17 Mar 2021 10:31:03 -0400 Subject: [PATCH 53/55] add error returns missing from protoc to prevent it from exiting with a successful return value when writing the zip file fails --- src/google/protobuf/compiler/command_line_interface.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index b0b2963d2d..3705e369c6 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -586,10 +586,12 @@ bool CommandLineInterface::GeneratorContextImpl::WriteAllToZip( if (stream.GetErrno() != 0) { std::cerr << filename << ": " << strerror(stream.GetErrno()) << std::endl; + return false; } if (!stream.Close()) { std::cerr << filename << ": " << strerror(stream.GetErrno()) << std::endl; + return false; } return true; From 53b0cce27b0d0b3b894bf7a599cf0c9133c7ddd8 Mon Sep 17 00:00:00 2001 From: Levon Ter-Grigoryan Date: Tue, 16 Mar 2021 21:15:31 +0100 Subject: [PATCH 54/55] Fix -Wsuggest-destructor-override for generated C++ proto classes. --- src/google/protobuf/any.pb.h | 2 +- src/google/protobuf/api.pb.h | 6 +-- .../protobuf/compiler/cpp/cpp_message.cc | 2 +- src/google/protobuf/compiler/plugin.pb.h | 8 +-- src/google/protobuf/descriptor.pb.h | 54 +++++++++---------- src/google/protobuf/duration.pb.h | 2 +- src/google/protobuf/empty.pb.h | 2 +- src/google/protobuf/field_mask.pb.h | 2 +- src/google/protobuf/source_context.pb.h | 2 +- src/google/protobuf/struct.pb.h | 6 +-- src/google/protobuf/timestamp.pb.h | 2 +- src/google/protobuf/type.pb.h | 10 ++-- src/google/protobuf/wrappers.pb.h | 18 +++---- 13 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index a08f962f78..3113a79b2b 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -69,7 +69,7 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Any) */ { public: inline Any() : Any(nullptr) {} - virtual ~Any(); + ~Any() override; explicit constexpr Any(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Any(const Any& from); diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 8e5ebf8500..5abbe170ee 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -79,7 +79,7 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Api) */ { public: inline Api() : Api(nullptr) {} - virtual ~Api(); + ~Api() override; explicit constexpr Api(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Api(const Api& from); @@ -322,7 +322,7 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ { public: inline Method() : Method(nullptr) {} - virtual ~Method(); + ~Method() override; explicit constexpr Method(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Method(const Method& from); @@ -543,7 +543,7 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ { public: inline Mixin() : Mixin(nullptr) {} - virtual ~Mixin(); + ~Mixin() override; explicit constexpr Mixin(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Mixin(const Mixin& from); diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 73e66ae90f..8a43bbcb1a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -1092,7 +1092,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format( "inline $classname$() : $classname$(nullptr) {}\n" - "virtual ~$classname$();\n" + "~$classname$() override;\n" "explicit constexpr " "$classname$(::$proto_ns$::internal::ConstantInitialized);\n" "\n" diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 6f59291f88..d620297210 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -115,7 +115,7 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ { public: inline Version() : Version(nullptr) {} - virtual ~Version(); + ~Version() override; explicit constexpr Version(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Version(const Version& from); @@ -308,7 +308,7 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ { public: inline CodeGeneratorRequest() : CodeGeneratorRequest(nullptr) {} - virtual ~CodeGeneratorRequest(); + ~CodeGeneratorRequest() override; explicit constexpr CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); CodeGeneratorRequest(const CodeGeneratorRequest& from); @@ -522,7 +522,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ { public: inline CodeGeneratorResponse_File() : CodeGeneratorResponse_File(nullptr) {} - virtual ~CodeGeneratorResponse_File(); + ~CodeGeneratorResponse_File() override; explicit constexpr CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from); @@ -730,7 +730,7 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ { public: inline CodeGeneratorResponse() : CodeGeneratorResponse(nullptr) {} - virtual ~CodeGeneratorResponse(); + ~CodeGeneratorResponse() override; explicit constexpr CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); CodeGeneratorResponse(const CodeGeneratorResponse& from); diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index e00562b314..466226bff7 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -333,7 +333,7 @@ class PROTOBUF_EXPORT FileDescriptorSet PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ { public: inline FileDescriptorSet() : FileDescriptorSet(nullptr) {} - virtual ~FileDescriptorSet(); + ~FileDescriptorSet() override; explicit constexpr FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FileDescriptorSet(const FileDescriptorSet& from); @@ -480,7 +480,7 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ { public: inline FileDescriptorProto() : FileDescriptorProto(nullptr) {} - virtual ~FileDescriptorProto(); + ~FileDescriptorProto() override; explicit constexpr FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FileDescriptorProto(const FileDescriptorProto& from); @@ -862,7 +862,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ { public: inline DescriptorProto_ExtensionRange() : DescriptorProto_ExtensionRange(nullptr) {} - virtual ~DescriptorProto_ExtensionRange(); + ~DescriptorProto_ExtensionRange() override; explicit constexpr DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from); @@ -1040,7 +1040,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ { public: inline DescriptorProto_ReservedRange() : DescriptorProto_ReservedRange(nullptr) {} - virtual ~DescriptorProto_ReservedRange(); + ~DescriptorProto_ReservedRange() override; explicit constexpr DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from); @@ -1198,7 +1198,7 @@ class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ { public: inline DescriptorProto() : DescriptorProto(nullptr) {} - virtual ~DescriptorProto(); + ~DescriptorProto() override; explicit constexpr DescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); DescriptorProto(const DescriptorProto& from); @@ -1535,7 +1535,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ExtensionRangeOptions) */ { public: inline ExtensionRangeOptions() : ExtensionRangeOptions(nullptr) {} - virtual ~ExtensionRangeOptions(); + ~ExtensionRangeOptions() override; explicit constexpr ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ExtensionRangeOptions(const ExtensionRangeOptions& from); @@ -1685,7 +1685,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ { public: inline FieldDescriptorProto() : FieldDescriptorProto(nullptr) {} - virtual ~FieldDescriptorProto(); + ~FieldDescriptorProto() override; explicit constexpr FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FieldDescriptorProto(const FieldDescriptorProto& from); @@ -2102,7 +2102,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ { public: inline OneofDescriptorProto() : OneofDescriptorProto(nullptr) {} - virtual ~OneofDescriptorProto(); + ~OneofDescriptorProto() override; explicit constexpr OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); OneofDescriptorProto(const OneofDescriptorProto& from); @@ -2270,7 +2270,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto.EnumReservedRange) */ { public: inline EnumDescriptorProto_EnumReservedRange() : EnumDescriptorProto_EnumReservedRange(nullptr) {} - virtual ~EnumDescriptorProto_EnumReservedRange(); + ~EnumDescriptorProto_EnumReservedRange() override; explicit constexpr EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from); @@ -2428,7 +2428,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ { public: inline EnumDescriptorProto() : EnumDescriptorProto(nullptr) {} - virtual ~EnumDescriptorProto(); + ~EnumDescriptorProto() override; explicit constexpr EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumDescriptorProto(const EnumDescriptorProto& from); @@ -2664,7 +2664,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ { public: inline EnumValueDescriptorProto() : EnumValueDescriptorProto(nullptr) {} - virtual ~EnumValueDescriptorProto(); + ~EnumValueDescriptorProto() override; explicit constexpr EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumValueDescriptorProto(const EnumValueDescriptorProto& from); @@ -2847,7 +2847,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ { public: inline ServiceDescriptorProto() : ServiceDescriptorProto(nullptr) {} - virtual ~ServiceDescriptorProto(); + ~ServiceDescriptorProto() override; explicit constexpr ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ServiceDescriptorProto(const ServiceDescriptorProto& from); @@ -3035,7 +3035,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ { public: inline MethodDescriptorProto() : MethodDescriptorProto(nullptr) {} - virtual ~MethodDescriptorProto(); + ~MethodDescriptorProto() override; explicit constexpr MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); MethodDescriptorProto(const MethodDescriptorProto& from); @@ -3273,7 +3273,7 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ { public: inline FileOptions() : FileOptions(nullptr) {} - virtual ~FileOptions(); + ~FileOptions() override; explicit constexpr FileOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FileOptions(const FileOptions& from); @@ -3806,7 +3806,7 @@ class PROTOBUF_EXPORT MessageOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ { public: inline MessageOptions() : MessageOptions(nullptr) {} - virtual ~MessageOptions(); + ~MessageOptions() override; explicit constexpr MessageOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); MessageOptions(const MessageOptions& from); @@ -4017,7 +4017,7 @@ class PROTOBUF_EXPORT FieldOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ { public: inline FieldOptions() : FieldOptions(nullptr) {} - virtual ~FieldOptions(); + ~FieldOptions() override; explicit constexpr FieldOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FieldOptions(const FieldOptions& from); @@ -4322,7 +4322,7 @@ class PROTOBUF_EXPORT OneofOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ { public: inline OneofOptions() : OneofOptions(nullptr) {} - virtual ~OneofOptions(); + ~OneofOptions() override; explicit constexpr OneofOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); OneofOptions(const OneofOptions& from); @@ -4472,7 +4472,7 @@ class PROTOBUF_EXPORT EnumOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ { public: inline EnumOptions() : EnumOptions(nullptr) {} - virtual ~EnumOptions(); + ~EnumOptions() override; explicit constexpr EnumOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumOptions(const EnumOptions& from); @@ -4653,7 +4653,7 @@ class PROTOBUF_EXPORT EnumValueOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ { public: inline EnumValueOptions() : EnumValueOptions(nullptr) {} - virtual ~EnumValueOptions(); + ~EnumValueOptions() override; explicit constexpr EnumValueOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumValueOptions(const EnumValueOptions& from); @@ -4819,7 +4819,7 @@ class PROTOBUF_EXPORT ServiceOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ { public: inline ServiceOptions() : ServiceOptions(nullptr) {} - virtual ~ServiceOptions(); + ~ServiceOptions() override; explicit constexpr ServiceOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ServiceOptions(const ServiceOptions& from); @@ -4985,7 +4985,7 @@ class PROTOBUF_EXPORT MethodOptions PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ { public: inline MethodOptions() : MethodOptions(nullptr) {} - virtual ~MethodOptions(); + ~MethodOptions() override; explicit constexpr MethodOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); MethodOptions(const MethodOptions& from); @@ -5198,7 +5198,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ { public: inline UninterpretedOption_NamePart() : UninterpretedOption_NamePart(nullptr) {} - virtual ~UninterpretedOption_NamePart(); + ~UninterpretedOption_NamePart() override; explicit constexpr UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from); @@ -5364,7 +5364,7 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ { public: inline UninterpretedOption() : UninterpretedOption(nullptr) {} - virtual ~UninterpretedOption(); + ~UninterpretedOption() override; explicit constexpr UninterpretedOption(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); UninterpretedOption(const UninterpretedOption& from); @@ -5619,7 +5619,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ { public: inline SourceCodeInfo_Location() : SourceCodeInfo_Location(nullptr) {} - virtual ~SourceCodeInfo_Location(); + ~SourceCodeInfo_Location() override; explicit constexpr SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); SourceCodeInfo_Location(const SourceCodeInfo_Location& from); @@ -5863,7 +5863,7 @@ class PROTOBUF_EXPORT SourceCodeInfo PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ { public: inline SourceCodeInfo() : SourceCodeInfo(nullptr) {} - virtual ~SourceCodeInfo(); + ~SourceCodeInfo() override; explicit constexpr SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); SourceCodeInfo(const SourceCodeInfo& from); @@ -6012,7 +6012,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ { public: inline GeneratedCodeInfo_Annotation() : GeneratedCodeInfo_Annotation(nullptr) {} - virtual ~GeneratedCodeInfo_Annotation(); + ~GeneratedCodeInfo_Annotation() override; explicit constexpr GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from); @@ -6215,7 +6215,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ { public: inline GeneratedCodeInfo() : GeneratedCodeInfo(nullptr) {} - virtual ~GeneratedCodeInfo(); + ~GeneratedCodeInfo() override; explicit constexpr GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); GeneratedCodeInfo(const GeneratedCodeInfo& from); diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 598a608f2f..e584d67c41 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -69,7 +69,7 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Duration) */ { public: inline Duration() : Duration(nullptr) {} - virtual ~Duration(); + ~Duration() override; explicit constexpr Duration(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Duration(const Duration& from); diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 392550d786..123d58afc8 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -69,7 +69,7 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ { public: inline Empty() : Empty(nullptr) {} - virtual ~Empty(); + ~Empty() override; explicit constexpr Empty(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Empty(const Empty& from); diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 03789f3bec..02553ca376 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -69,7 +69,7 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldMask) */ { public: inline FieldMask() : FieldMask(nullptr) {} - virtual ~FieldMask(); + ~FieldMask() override; explicit constexpr FieldMask(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FieldMask(const FieldMask& from); diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 9edacf4e2f..d11218150e 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -69,7 +69,7 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceContext) */ { public: inline SourceContext() : SourceContext(nullptr) {} - virtual ~SourceContext(); + ~SourceContext() override; explicit constexpr SourceContext(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); SourceContext(const SourceContext& from); diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index fea5719ae8..dd56d9bd98 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -134,7 +134,7 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ { public: inline Struct() : Struct(nullptr) {} - virtual ~Struct(); + ~Struct() override; explicit constexpr Struct(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Struct(const Struct& from); @@ -278,7 +278,7 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ { public: inline Value() : Value(nullptr) {} - virtual ~Value(); + ~Value() override; explicit constexpr Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Value(const Value& from); @@ -530,7 +530,7 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ { public: inline ListValue() : ListValue(nullptr) {} - virtual ~ListValue(); + ~ListValue() override; explicit constexpr ListValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ListValue(const ListValue& from); diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 1ab2211bb6..ed4d23a70a 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -69,7 +69,7 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Timestamp) */ { public: inline Timestamp() : Timestamp(nullptr) {} - virtual ~Timestamp(); + ~Timestamp() override; explicit constexpr Timestamp(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Timestamp(const Timestamp& from); diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index ea8a1359f2..fabd21185c 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -182,7 +182,7 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Type) */ { public: inline Type() : Type(nullptr) {} - virtual ~Type(); + ~Type() override; explicit constexpr Type(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Type(const Type& from); @@ -415,7 +415,7 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ { public: inline Field() : Field(nullptr) {} - virtual ~Field(); + ~Field() override; explicit constexpr Field(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Field(const Field& from); @@ -772,7 +772,7 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ { public: inline Enum() : Enum(nullptr) {} - virtual ~Enum(); + ~Enum() override; explicit constexpr Enum(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Enum(const Enum& from); @@ -979,7 +979,7 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ { public: inline EnumValue() : EnumValue(nullptr) {} - virtual ~EnumValue(); + ~EnumValue() override; explicit constexpr EnumValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumValue(const EnumValue& from); @@ -1146,7 +1146,7 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ { public: inline Option() : Option(nullptr) {} - virtual ~Option(); + ~Option() override; explicit constexpr Option(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Option(const Option& from); diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index a3bbd8550d..2d7963bf3f 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -101,7 +101,7 @@ class PROTOBUF_EXPORT DoubleValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DoubleValue) */ { public: inline DoubleValue() : DoubleValue(nullptr) {} - virtual ~DoubleValue(); + ~DoubleValue() override; explicit constexpr DoubleValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); DoubleValue(const DoubleValue& from); @@ -232,7 +232,7 @@ class PROTOBUF_EXPORT FloatValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FloatValue) */ { public: inline FloatValue() : FloatValue(nullptr) {} - virtual ~FloatValue(); + ~FloatValue() override; explicit constexpr FloatValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FloatValue(const FloatValue& from); @@ -363,7 +363,7 @@ class PROTOBUF_EXPORT Int64Value PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int64Value) */ { public: inline Int64Value() : Int64Value(nullptr) {} - virtual ~Int64Value(); + ~Int64Value() override; explicit constexpr Int64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Int64Value(const Int64Value& from); @@ -494,7 +494,7 @@ class PROTOBUF_EXPORT UInt64Value PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt64Value) */ { public: inline UInt64Value() : UInt64Value(nullptr) {} - virtual ~UInt64Value(); + ~UInt64Value() override; explicit constexpr UInt64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); UInt64Value(const UInt64Value& from); @@ -625,7 +625,7 @@ class PROTOBUF_EXPORT Int32Value PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int32Value) */ { public: inline Int32Value() : Int32Value(nullptr) {} - virtual ~Int32Value(); + ~Int32Value() override; explicit constexpr Int32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Int32Value(const Int32Value& from); @@ -756,7 +756,7 @@ class PROTOBUF_EXPORT UInt32Value PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt32Value) */ { public: inline UInt32Value() : UInt32Value(nullptr) {} - virtual ~UInt32Value(); + ~UInt32Value() override; explicit constexpr UInt32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); UInt32Value(const UInt32Value& from); @@ -887,7 +887,7 @@ class PROTOBUF_EXPORT BoolValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BoolValue) */ { public: inline BoolValue() : BoolValue(nullptr) {} - virtual ~BoolValue(); + ~BoolValue() override; explicit constexpr BoolValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); BoolValue(const BoolValue& from); @@ -1018,7 +1018,7 @@ class PROTOBUF_EXPORT StringValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.StringValue) */ { public: inline StringValue() : StringValue(nullptr) {} - virtual ~StringValue(); + ~StringValue() override; explicit constexpr StringValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); StringValue(const StringValue& from); @@ -1154,7 +1154,7 @@ class PROTOBUF_EXPORT BytesValue PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BytesValue) */ { public: inline BytesValue() : BytesValue(nullptr) {} - virtual ~BytesValue(); + ~BytesValue() override; explicit constexpr BytesValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); BytesValue(const BytesValue& from); From 9daba367f4b5a545fb0ae8781c04df33131ea58f Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 22 Mar 2021 16:29:46 -0700 Subject: [PATCH 55/55] Updated changelog. --- CHANGES.txt | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index ef79313b59..99d9ad712d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,9 +9,32 @@ Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) * For iterator-pair function parameter types, take both iterators by value. * Code-space savings and perhaps some modest performance improvements in RepeatedPtrField. + * Eliminate nullptr check from every tag parse. + * Remove unused _$name$_cached_byte_size_ fields. + * Serialize extension ranges together when not broken by a proto field in the + middle. + * Do out-of-line allocation and deallocation of string object in ArenaString. + * Streamline ParseContext::ParseMessage to avoid code bloat and improve + performance. + * New member functions RepeatedField::Assign, RepeatedPtrField::{Add, Assign}. + * Fix undefined behavior warning due to innocuous uninitialization of value + on an error path. + * Avoid expensive inlined code space for encoding message length for messages + >= 128 bytes and instead do a procedure call to a shared out-of-line routine. Java: - * Exceptions thrown while reading from an InputStream in parseFrom are now included as causes. + * Exceptions thrown while reading from an InputStream in parseFrom are now + included as causes. + * Support potentially more efficient proto parsing from RopeByteStrings. + * Clarify runtime of ByteString.Output.toStringBuffer(). + + Python + * Fixed a bug in text format where a trailing colon was printed for repeated field. + * When TextFormat encounters a duplicate message map key, replace the current + one instead of merging. + + JavaScript + * Make Any.pack() chainable. 2021-03-10 version 3.15.6 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)