You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/01/12 02:21:46 UTC

[1/4] mesos git commit: Added test for protobuf::parse with nested parse errors.

Repository: mesos
Updated Branches:
  refs/heads/master 494528290 -> 9632dd841


Added test for protobuf::parse with nested parse errors.

Review: https://reviews.apache.org/r/42058


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9632dd84
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9632dd84
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9632dd84

Branch: refs/heads/master
Commit: 9632dd84134b96ada563b9b26358d507a2cb0d9a
Parents: d291930
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Jan 11 17:06:53 2016 -0800
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Jan 11 17:21:36 2016 -0800

----------------------------------------------------------------------
 .../3rdparty/stout/tests/protobuf_tests.cpp     | 27 ++++++++++++++++++++
 1 file changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9632dd84/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
index 1c453a5..34bb252 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
@@ -387,3 +387,30 @@ TEST(ProtobufTest, ParseJSONNull)
 
   EXPECT_ERROR(protobuf::parse<tests::Nested>(json.get()));
 }
+
+
+TEST(ProtobufTest, ParseJSONNestedError)
+{
+  // Here we trigger an error parsing the 'nested' message.
+  string message =
+    "{"
+    "  \"b\": true,"
+    "  \"str\": \"string\","
+    "  \"bytes\": \"Ynl0ZXM=\","
+    "  \"f\": 1.0,"
+    "  \"d\": 1.0,"
+    "  \"e\": \"ONE\","
+    "  \"nested\": {"
+    "      \"str\": 1.0" // Error due to int for string type.
+    "  }"
+    "}";
+
+  Try<JSON::Object> json = JSON::parse<JSON::Object>(message);
+  ASSERT_SOME(json);
+
+  Try<tests::Message> parse = protobuf::parse<tests::Message>(json.get());
+  ASSERT_ERROR(parse);
+
+  EXPECT_TRUE(strings::contains(
+      parse.error(), "Not expecting a JSON number for field"));
+}


[3/4] mesos git commit: Fixed protobuf::parse to surface nested message parsing errors.

Posted by bm...@apache.org.
Fixed protobuf::parse to surface nested message parsing errors.

Previously, errors parsing nested messages were ignored.

Review: https://reviews.apache.org/r/42167/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d291930d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d291930d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d291930d

Branch: refs/heads/master
Commit: d291930d93c5e679c698ee7a8480e244afcea16d
Parents: bb61e14
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Jan 11 16:54:40 2016 -0800
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Jan 11 17:21:36 2016 -0800

----------------------------------------------------------------------
 .../3rdparty/stout/include/stout/protobuf.hpp    | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d291930d/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
index adb68c3..22cb5d9 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
@@ -332,10 +332,25 @@ struct Parser : boost::static_visitor<Try<Nothing> >
   {
     switch (field->type()) {
       case google::protobuf::FieldDescriptor::TYPE_MESSAGE:
+        // TODO(gilbert): We currently push up the nested error
+        // messages without wrapping the error message (due to
+        // the recursive nature of parse). We should pass along
+        // variable information in order to construct a helpful
+        // error message, e.g. "Failed to parse field 'a.b.c': ...".
         if (field->is_repeated()) {
-          parse(reflection->AddMessage(message, field), object);
+          Try<Nothing> parse =
+            internal::parse(reflection->AddMessage(message, field), object);
+
+          if (parse.isError()) {
+            return parse;
+          }
         } else {
-          parse(reflection->MutableMessage(message, field), object);
+          Try<Nothing> parse =
+            internal::parse(reflection->MutableMessage(message, field), object);
+
+          if (parse.isError()) {
+            return parse;
+          }
         }
         break;
       default:


[4/4] mesos git commit: Fixed stout's protobuf::parse to support JSON null values.

Posted by bm...@apache.org.
Fixed stout's protobuf::parse to support JSON null values.

Review: https://reviews.apache.org/r/42166/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d9db0363
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d9db0363
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d9db0363

Branch: refs/heads/master
Commit: d9db0363e16b9f1400f511d95c084f8c8ba264dc
Parents: 4945282
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Jan 11 16:08:21 2016 -0800
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Jan 11 17:21:36 2016 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d9db0363/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
index 98ea477..adb68c3 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp
@@ -488,7 +488,10 @@ struct Parser : boost::static_visitor<Try<Nothing> >
 
   Try<Nothing> operator()(const JSON::Null&) const
   {
-    return Error("Not expecting a JSON null");
+    // We treat 'null' as an unset field. Note that we allow
+    // unset required fields here since the top-level parse
+    // function is responsible for checking 'IsInitialized'.
+    return Nothing();
   }
 
 private:


[2/4] mesos git commit: Added test for protobuf::parse with JSON null.

Posted by bm...@apache.org.
Added test for protobuf::parse with JSON null.

Review: https://reviews.apache.org/r/41943/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/bb61e14a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/bb61e14a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/bb61e14a

Branch: refs/heads/master
Commit: bb61e14a9b6e45de4e89f89ed127158916e33d0d
Parents: d9db036
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Jan 11 16:38:54 2016 -0800
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Jan 11 17:21:36 2016 -0800

----------------------------------------------------------------------
 .../3rdparty/stout/tests/protobuf_tests.cpp     |  48 ++++++
 .../3rdparty/stout/tests/protobuf_tests.pb.cc   | 167 ++++++++++++++++---
 .../3rdparty/stout/tests/protobuf_tests.pb.h    | 152 ++++++++++++++++-
 .../3rdparty/stout/tests/protobuf_tests.proto   |   4 +-
 4 files changed, 341 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/bb61e14a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
index bf2a2b8..1c453a5 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
@@ -339,3 +339,51 @@ TEST(ProtobufTest, ParseJSONArray)
   EXPECT_EQ(message, repeated.Get(0));
   EXPECT_EQ(message, repeated.Get(1));
 }
+
+
+TEST(ProtobufTest, ParseJSONNull)
+{
+  tests::Nested nested;
+  nested.set_str("value");
+
+  // Test message with optional field set to 'null'.
+  string message =
+    "{"
+    "  \"str\": \"value\","
+    "  \"optional_str\": null"
+    "}";
+
+  Try<JSON::Object> json = JSON::parse<JSON::Object>(message);
+  ASSERT_SOME(json);
+
+  Try<tests::Nested> parse = protobuf::parse<tests::Nested>(json.get());
+  ASSERT_SOME(parse);
+
+  EXPECT_EQ(parse->SerializeAsString(), nested.SerializeAsString());
+
+  // Test message with repeated field set to 'null'.
+  message =
+    "{"
+    "  \"str\": \"value\","
+    "  \"repeated_str\": null"
+    "}";
+
+  json = JSON::parse<JSON::Object>(message);
+  ASSERT_SOME(json);
+
+  parse = protobuf::parse<tests::Nested>(json.get());
+  ASSERT_SOME(parse);
+
+  EXPECT_EQ(parse->SerializeAsString(), nested.SerializeAsString());
+
+  // Test message with required field set to 'null'.
+  message =
+    "{"
+    "  \"str\": null"
+    "}";
+
+  json = JSON::parse<JSON::Object>(message);
+  ASSERT_SOME(json);
+
+  EXPECT_ERROR(protobuf::parse<tests::Nested>(json.get()));
+}

http://git-wip-us.apache.org/repos/asf/mesos/blob/bb61e14a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.cc
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.cc b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.cc
index 797b3b0..fb11b11 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.cc
+++ b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.cc
@@ -44,8 +44,10 @@ void protobuf_AssignDesc_protobuf_5ftests_2eproto() {
       "protobuf_tests.proto");
   GOOGLE_CHECK(file != NULL);
   Nested_descriptor_ = file->message_type(0);
-  static const int Nested_offsets_[1] = {
+  static const int Nested_offsets_[3] = {
     GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Nested, str_),
+    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Nested, optional_str_),
+    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Nested, repeated_str_),
   };
   Nested_reflection_ =
     new ::google::protobuf::internal::GeneratedMessageReflection(
@@ -175,27 +177,28 @@ void protobuf_AddDesc_protobuf_5ftests_2eproto() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
 
   ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-    "\n\024protobuf_tests.proto\022\005tests\"\025\n\006Nested\022"
-    "\013\n\003str\030\001 \001(\t\",\n\rSimpleMessage\022\n\n\002id\030\001 \002("
-    "\t\022\017\n\007numbers\030\002 \003(\005\"\376\004\n\007Message\022\t\n\001b\030\032 \002("
-    "\010\022\013\n\003str\030\001 \002(\t\022\r\n\005bytes\030\002 \002(\014\022\r\n\005int32\030\003"
-    " \001(\005\022\r\n\005int64\030\004 \001(\003\022\016\n\006uint32\030\005 \001(\r\022\016\n\006u"
-    "int64\030\006 \001(\004\022\016\n\006sint32\030\007 \001(\021\022\016\n\006sint64\030\010 "
-    "\001(\022\022\t\n\001f\030\t \002(\002\022\t\n\001d\030\n \002(\001\022\026\n\001e\030\013 \002(\0162\013.t"
-    "ests.Enum\022\035\n\006nested\030\014 \002(\0132\r.tests.Nested"
-    "\022\025\n\rrepeated_bool\030\033 \003(\010\022\027\n\017repeated_stri"
-    "ng\030\r \003(\t\022\026\n\016repeated_bytes\030\016 \003(\014\022\026\n\016repe"
-    "ated_int32\030\017 \003(\005\022\026\n\016repeated_int64\030\020 \003(\003"
-    "\022\027\n\017repeated_uint32\030\021 \003(\r\022\027\n\017repeated_ui"
-    "nt64\030\022 \003(\004\022\027\n\017repeated_sint32\030\023 \003(\021\022\027\n\017r"
-    "epeated_sint64\030\024 \003(\022\022\026\n\016repeated_float\030\025"
-    " \003(\002\022\027\n\017repeated_double\030\026 \003(\001\022\"\n\rrepeate"
-    "d_enum\030\027 \003(\0162\013.tests.Enum\022&\n\017repeated_ne"
-    "sted\030\030 \003(\0132\r.tests.Nested\022\r\n\005empty\030\031 \003(\t"
-    "\022\034\n\020optional_default\030\034 \001(\001:\00242\022\033\n\023option"
-    "al_no_default\030\035 \001(\001\"4\n\014ArrayMessage\022$\n\006v"
-    "alues\030\001 \003(\0132\024.tests.SimpleMessage*\030\n\004Enu"
-    "m\022\007\n\003ONE\020\001\022\007\n\003TWO\020\002", 819);
+    "\n\024protobuf_tests.proto\022\005tests\"A\n\006Nested\022"
+    "\013\n\003str\030\001 \002(\t\022\024\n\014optional_str\030\002 \001(\t\022\024\n\014re"
+    "peated_str\030\003 \003(\t\",\n\rSimpleMessage\022\n\n\002id\030"
+    "\001 \002(\t\022\017\n\007numbers\030\002 \003(\005\"\376\004\n\007Message\022\t\n\001b\030"
+    "\032 \002(\010\022\013\n\003str\030\001 \002(\t\022\r\n\005bytes\030\002 \002(\014\022\r\n\005int"
+    "32\030\003 \001(\005\022\r\n\005int64\030\004 \001(\003\022\016\n\006uint32\030\005 \001(\r\022"
+    "\016\n\006uint64\030\006 \001(\004\022\016\n\006sint32\030\007 \001(\021\022\016\n\006sint6"
+    "4\030\010 \001(\022\022\t\n\001f\030\t \002(\002\022\t\n\001d\030\n \002(\001\022\026\n\001e\030\013 \002(\016"
+    "2\013.tests.Enum\022\035\n\006nested\030\014 \002(\0132\r.tests.Ne"
+    "sted\022\025\n\rrepeated_bool\030\033 \003(\010\022\027\n\017repeated_"
+    "string\030\r \003(\t\022\026\n\016repeated_bytes\030\016 \003(\014\022\026\n\016"
+    "repeated_int32\030\017 \003(\005\022\026\n\016repeated_int64\030\020"
+    " \003(\003\022\027\n\017repeated_uint32\030\021 \003(\r\022\027\n\017repeate"
+    "d_uint64\030\022 \003(\004\022\027\n\017repeated_sint32\030\023 \003(\021\022"
+    "\027\n\017repeated_sint64\030\024 \003(\022\022\026\n\016repeated_flo"
+    "at\030\025 \003(\002\022\027\n\017repeated_double\030\026 \003(\001\022\"\n\rrep"
+    "eated_enum\030\027 \003(\0162\013.tests.Enum\022&\n\017repeate"
+    "d_nested\030\030 \003(\0132\r.tests.Nested\022\r\n\005empty\030\031"
+    " \003(\t\022\034\n\020optional_default\030\034 \001(\001:\00242\022\033\n\023op"
+    "tional_no_default\030\035 \001(\001\"4\n\014ArrayMessage\022"
+    "$\n\006values\030\001 \003(\0132\024.tests.SimpleMessage*\030\n"
+    "\004Enum\022\007\n\003ONE\020\001\022\007\n\003TWO\020\002", 863);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "protobuf_tests.proto", &protobuf_RegisterTypes);
   Nested::default_instance_ = new Nested();
@@ -234,6 +237,8 @@ bool Enum_IsValid(int value) {
 
 #ifndef _MSC_VER
 const int Nested::kStrFieldNumber;
+const int Nested::kOptionalStrFieldNumber;
+const int Nested::kRepeatedStrFieldNumber;
 #endif  // !_MSC_VER
 
 Nested::Nested()
@@ -253,6 +258,7 @@ Nested::Nested(const Nested& from)
 void Nested::SharedCtor() {
   _cached_size_ = 0;
   str_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
+  optional_str_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
   ::memset(_has_bits_, 0, sizeof(_has_bits_));
 }
 
@@ -264,6 +270,9 @@ void Nested::SharedDtor() {
   if (str_ != &::google::protobuf::internal::kEmptyString) {
     delete str_;
   }
+  if (optional_str_ != &::google::protobuf::internal::kEmptyString) {
+    delete optional_str_;
+  }
   if (this != default_instance_) {
   }
 }
@@ -296,7 +305,13 @@ void Nested::Clear() {
         str_->clear();
       }
     }
+    if (has_optional_str()) {
+      if (optional_str_ != &::google::protobuf::internal::kEmptyString) {
+        optional_str_->clear();
+      }
+    }
   }
+  repeated_str_.Clear();
   ::memset(_has_bits_, 0, sizeof(_has_bits_));
   mutable_unknown_fields()->Clear();
 }
@@ -307,7 +322,7 @@ bool Nested::MergePartialFromCodedStream(
   ::google::protobuf::uint32 tag;
   while ((tag = input->ReadTag()) != 0) {
     switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
-      // optional string str = 1;
+      // required string str = 1;
       case 1: {
         if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
             ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
@@ -319,6 +334,42 @@ bool Nested::MergePartialFromCodedStream(
         } else {
           goto handle_uninterpreted;
         }
+        if (input->ExpectTag(18)) goto parse_optional_str;
+        break;
+      }
+
+      // optional string optional_str = 2;
+      case 2: {
+        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+         parse_optional_str:
+          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+                input, this->mutable_optional_str()));
+          ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+            this->optional_str().data(), this->optional_str().length(),
+            ::google::protobuf::internal::WireFormat::PARSE);
+        } else {
+          goto handle_uninterpreted;
+        }
+        if (input->ExpectTag(26)) goto parse_repeated_str;
+        break;
+      }
+
+      // repeated string repeated_str = 3;
+      case 3: {
+        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+         parse_repeated_str:
+          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+                input, this->add_repeated_str()));
+          ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+            this->repeated_str(this->repeated_str_size() - 1).data(),
+            this->repeated_str(this->repeated_str_size() - 1).length(),
+            ::google::protobuf::internal::WireFormat::PARSE);
+        } else {
+          goto handle_uninterpreted;
+        }
+        if (input->ExpectTag(26)) goto parse_repeated_str;
         if (input->ExpectAtEnd()) return true;
         break;
       }
@@ -341,7 +392,7 @@ bool Nested::MergePartialFromCodedStream(
 
 void Nested::SerializeWithCachedSizes(
     ::google::protobuf::io::CodedOutputStream* output) const {
-  // optional string str = 1;
+  // required string str = 1;
   if (has_str()) {
     ::google::protobuf::internal::WireFormat::VerifyUTF8String(
       this->str().data(), this->str().length(),
@@ -350,6 +401,24 @@ void Nested::SerializeWithCachedSizes(
       1, this->str(), output);
   }
 
+  // optional string optional_str = 2;
+  if (has_optional_str()) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+      this->optional_str().data(), this->optional_str().length(),
+      ::google::protobuf::internal::WireFormat::SERIALIZE);
+    ::google::protobuf::internal::WireFormatLite::WriteString(
+      2, this->optional_str(), output);
+  }
+
+  // repeated string repeated_str = 3;
+  for (int i = 0; i < this->repeated_str_size(); i++) {
+  ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+    this->repeated_str(i).data(), this->repeated_str(i).length(),
+    ::google::protobuf::internal::WireFormat::SERIALIZE);
+    ::google::protobuf::internal::WireFormatLite::WriteString(
+      3, this->repeated_str(i), output);
+  }
+
   if (!unknown_fields().empty()) {
     ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
         unknown_fields(), output);
@@ -358,7 +427,7 @@ void Nested::SerializeWithCachedSizes(
 
 ::google::protobuf::uint8* Nested::SerializeWithCachedSizesToArray(
     ::google::protobuf::uint8* target) const {
-  // optional string str = 1;
+  // required string str = 1;
   if (has_str()) {
     ::google::protobuf::internal::WireFormat::VerifyUTF8String(
       this->str().data(), this->str().length(),
@@ -368,6 +437,25 @@ void Nested::SerializeWithCachedSizes(
         1, this->str(), target);
   }
 
+  // optional string optional_str = 2;
+  if (has_optional_str()) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+      this->optional_str().data(), this->optional_str().length(),
+      ::google::protobuf::internal::WireFormat::SERIALIZE);
+    target =
+      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+        2, this->optional_str(), target);
+  }
+
+  // repeated string repeated_str = 3;
+  for (int i = 0; i < this->repeated_str_size(); i++) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+      this->repeated_str(i).data(), this->repeated_str(i).length(),
+      ::google::protobuf::internal::WireFormat::SERIALIZE);
+    target = ::google::protobuf::internal::WireFormatLite::
+      WriteStringToArray(3, this->repeated_str(i), target);
+  }
+
   if (!unknown_fields().empty()) {
     target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
         unknown_fields(), target);
@@ -379,14 +467,28 @@ int Nested::ByteSize() const {
   int total_size = 0;
 
   if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
-    // optional string str = 1;
+    // required string str = 1;
     if (has_str()) {
       total_size += 1 +
         ::google::protobuf::internal::WireFormatLite::StringSize(
           this->str());
     }
 
+    // optional string optional_str = 2;
+    if (has_optional_str()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::StringSize(
+          this->optional_str());
+    }
+
   }
+  // repeated string repeated_str = 3;
+  total_size += 1 * this->repeated_str_size();
+  for (int i = 0; i < this->repeated_str_size(); i++) {
+    total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
+      this->repeated_str(i));
+  }
+
   if (!unknown_fields().empty()) {
     total_size +=
       ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
@@ -412,10 +514,14 @@ void Nested::MergeFrom(const ::google::protobuf::Message& from) {
 
 void Nested::MergeFrom(const Nested& from) {
   GOOGLE_CHECK_NE(&from, this);
+  repeated_str_.MergeFrom(from.repeated_str_);
   if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
     if (from.has_str()) {
       set_str(from.str());
     }
+    if (from.has_optional_str()) {
+      set_optional_str(from.optional_str());
+    }
   }
   mutable_unknown_fields()->MergeFrom(from.unknown_fields());
 }
@@ -433,6 +539,7 @@ void Nested::CopyFrom(const Nested& from) {
 }
 
 bool Nested::IsInitialized() const {
+  if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
 
   return true;
 }
@@ -440,6 +547,8 @@ bool Nested::IsInitialized() const {
 void Nested::Swap(Nested* other) {
   if (other != this) {
     std::swap(str_, other->str_);
+    std::swap(optional_str_, other->optional_str_);
+    repeated_str_.Swap(&other->repeated_str_);
     std::swap(_has_bits_[0], other->_has_bits_[0]);
     _unknown_fields_.Swap(&other->_unknown_fields_);
     std::swap(_cached_size_, other->_cached_size_);
@@ -2139,6 +2248,12 @@ void Message::CopyFrom(const Message& from) {
 bool Message::IsInitialized() const {
   if ((_has_bits_[0] & 0x00001e07) != 0x00001e07) return false;
 
+  if (has_nested()) {
+    if (!this->nested().IsInitialized()) return false;
+  }
+  for (int i = 0; i < repeated_nested_size(); i++) {
+    if (!this->repeated_nested(i).IsInitialized()) return false;
+  }
   return true;
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/bb61e14a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.h
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.h b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.h
index 08793c9..3d1f130 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.h
+++ b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.pb.h
@@ -114,7 +114,7 @@ class Nested : public ::google::protobuf::Message {
 
   // accessors -------------------------------------------------------
 
-  // optional string str = 1;
+  // required string str = 1;
   inline bool has_str() const;
   inline void clear_str();
   static const int kStrFieldNumber = 1;
@@ -126,17 +126,49 @@ class Nested : public ::google::protobuf::Message {
   inline ::std::string* release_str();
   inline void set_allocated_str(::std::string* str);
 
+  // optional string optional_str = 2;
+  inline bool has_optional_str() const;
+  inline void clear_optional_str();
+  static const int kOptionalStrFieldNumber = 2;
+  inline const ::std::string& optional_str() const;
+  inline void set_optional_str(const ::std::string& value);
+  inline void set_optional_str(const char* value);
+  inline void set_optional_str(const char* value, size_t size);
+  inline ::std::string* mutable_optional_str();
+  inline ::std::string* release_optional_str();
+  inline void set_allocated_optional_str(::std::string* optional_str);
+
+  // repeated string repeated_str = 3;
+  inline int repeated_str_size() const;
+  inline void clear_repeated_str();
+  static const int kRepeatedStrFieldNumber = 3;
+  inline const ::std::string& repeated_str(int index) const;
+  inline ::std::string* mutable_repeated_str(int index);
+  inline void set_repeated_str(int index, const ::std::string& value);
+  inline void set_repeated_str(int index, const char* value);
+  inline void set_repeated_str(int index, const char* value, size_t size);
+  inline ::std::string* add_repeated_str();
+  inline void add_repeated_str(const ::std::string& value);
+  inline void add_repeated_str(const char* value);
+  inline void add_repeated_str(const char* value, size_t size);
+  inline const ::google::protobuf::RepeatedPtrField< ::std::string>& repeated_str() const;
+  inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_repeated_str();
+
   // @@protoc_insertion_point(class_scope:tests.Nested)
  private:
   inline void set_has_str();
   inline void clear_has_str();
+  inline void set_has_optional_str();
+  inline void clear_has_optional_str();
 
   ::google::protobuf::UnknownFieldSet _unknown_fields_;
 
   ::std::string* str_;
+  ::std::string* optional_str_;
+  ::google::protobuf::RepeatedPtrField< ::std::string> repeated_str_;
 
   mutable int _cached_size_;
-  ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
+  ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
 
   friend void  protobuf_AddDesc_protobuf_5ftests_2eproto();
   friend void protobuf_AssignDesc_protobuf_5ftests_2eproto();
@@ -763,7 +795,7 @@ class ArrayMessage : public ::google::protobuf::Message {
 
 // Nested
 
-// optional string str = 1;
+// required string str = 1;
 inline bool Nested::has_str() const {
   return (_has_bits_[0] & 0x00000001u) != 0;
 }
@@ -833,6 +865,120 @@ inline void Nested::set_allocated_str(::std::string* str) {
   }
 }
 
+// optional string optional_str = 2;
+inline bool Nested::has_optional_str() const {
+  return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void Nested::set_has_optional_str() {
+  _has_bits_[0] |= 0x00000002u;
+}
+inline void Nested::clear_has_optional_str() {
+  _has_bits_[0] &= ~0x00000002u;
+}
+inline void Nested::clear_optional_str() {
+  if (optional_str_ != &::google::protobuf::internal::kEmptyString) {
+    optional_str_->clear();
+  }
+  clear_has_optional_str();
+}
+inline const ::std::string& Nested::optional_str() const {
+  return *optional_str_;
+}
+inline void Nested::set_optional_str(const ::std::string& value) {
+  set_has_optional_str();
+  if (optional_str_ == &::google::protobuf::internal::kEmptyString) {
+    optional_str_ = new ::std::string;
+  }
+  optional_str_->assign(value);
+}
+inline void Nested::set_optional_str(const char* value) {
+  set_has_optional_str();
+  if (optional_str_ == &::google::protobuf::internal::kEmptyString) {
+    optional_str_ = new ::std::string;
+  }
+  optional_str_->assign(value);
+}
+inline void Nested::set_optional_str(const char* value, size_t size) {
+  set_has_optional_str();
+  if (optional_str_ == &::google::protobuf::internal::kEmptyString) {
+    optional_str_ = new ::std::string;
+  }
+  optional_str_->assign(reinterpret_cast<const char*>(value), size);
+}
+inline ::std::string* Nested::mutable_optional_str() {
+  set_has_optional_str();
+  if (optional_str_ == &::google::protobuf::internal::kEmptyString) {
+    optional_str_ = new ::std::string;
+  }
+  return optional_str_;
+}
+inline ::std::string* Nested::release_optional_str() {
+  clear_has_optional_str();
+  if (optional_str_ == &::google::protobuf::internal::kEmptyString) {
+    return NULL;
+  } else {
+    ::std::string* temp = optional_str_;
+    optional_str_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
+    return temp;
+  }
+}
+inline void Nested::set_allocated_optional_str(::std::string* optional_str) {
+  if (optional_str_ != &::google::protobuf::internal::kEmptyString) {
+    delete optional_str_;
+  }
+  if (optional_str) {
+    set_has_optional_str();
+    optional_str_ = optional_str;
+  } else {
+    clear_has_optional_str();
+    optional_str_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
+  }
+}
+
+// repeated string repeated_str = 3;
+inline int Nested::repeated_str_size() const {
+  return repeated_str_.size();
+}
+inline void Nested::clear_repeated_str() {
+  repeated_str_.Clear();
+}
+inline const ::std::string& Nested::repeated_str(int index) const {
+  return repeated_str_.Get(index);
+}
+inline ::std::string* Nested::mutable_repeated_str(int index) {
+  return repeated_str_.Mutable(index);
+}
+inline void Nested::set_repeated_str(int index, const ::std::string& value) {
+  repeated_str_.Mutable(index)->assign(value);
+}
+inline void Nested::set_repeated_str(int index, const char* value) {
+  repeated_str_.Mutable(index)->assign(value);
+}
+inline void Nested::set_repeated_str(int index, const char* value, size_t size) {
+  repeated_str_.Mutable(index)->assign(
+    reinterpret_cast<const char*>(value), size);
+}
+inline ::std::string* Nested::add_repeated_str() {
+  return repeated_str_.Add();
+}
+inline void Nested::add_repeated_str(const ::std::string& value) {
+  repeated_str_.Add()->assign(value);
+}
+inline void Nested::add_repeated_str(const char* value) {
+  repeated_str_.Add()->assign(value);
+}
+inline void Nested::add_repeated_str(const char* value, size_t size) {
+  repeated_str_.Add()->assign(reinterpret_cast<const char*>(value), size);
+}
+inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
+Nested::repeated_str() const {
+  return repeated_str_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::std::string>*
+Nested::mutable_repeated_str() {
+  return &repeated_str_;
+}
+
 // -------------------------------------------------------------------
 
 // SimpleMessage

http://git-wip-us.apache.org/repos/asf/mesos/blob/bb61e14a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.proto
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.proto b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.proto
index 4c11e23..229ac25 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.proto
+++ b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.proto
@@ -28,7 +28,9 @@ enum Enum {
 
 
 message Nested {
-  optional string str = 1;
+  required string str = 1;
+  optional string optional_str = 2;
+  repeated string repeated_str = 3;
 }