Index: third_party/protobuf/java/src/test/java/com/google/protobuf/map_initialization_order_test.proto |
diff --git a/third_party/protobuf/src/google/protobuf/unittest_optimize_for.proto b/third_party/protobuf/java/src/test/java/com/google/protobuf/map_initialization_order_test.proto |
similarity index 62% |
copy from third_party/protobuf/src/google/protobuf/unittest_optimize_for.proto |
copy to third_party/protobuf/java/src/test/java/com/google/protobuf/map_initialization_order_test.proto |
index feecbef8d4a90961b35be988402e49e74fed313c..b02ac599a5ed6387a46215393b4014d4bc70ea0d 100644 |
--- a/third_party/protobuf/src/google/protobuf/unittest_optimize_for.proto |
+++ b/third_party/protobuf/java/src/test/java/com/google/protobuf/map_initialization_order_test.proto |
@@ -1,6 +1,6 @@ |
// Protocol Buffers - Google's data interchange format |
// Copyright 2008 Google Inc. All rights reserved. |
-// http://code.google.com/p/protobuf/ |
+// 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 |
@@ -28,34 +28,34 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// Author: kenton@google.com (Kenton Varda) |
-// Based on original Protocol Buffers design by |
-// Sanjay Ghemawat, Jeff Dean, and others. |
-// |
-// A proto file which uses optimize_for = CODE_SIZE. |
- |
-import "google/protobuf/unittest.proto"; |
+// Regression test for a map initilaization order bug. The bug only manifests |
+// when: |
+// 1. A message contains map fields and is also extendable. |
+// 2. There is a file-level extension defined in the same file referencing |
+// the above message as the extension type. |
+// 3. The program executes in the following order: |
+// a. getDescriptor() is called on another message in the same file. |
+// b. use protobuf reflection to access the map field. |
+// The symptom is a NullPointerException being thrown. |
+syntax = "proto2"; |
-package protobuf_unittest; |
+package map_test; |
-option optimize_for = CODE_SIZE; |
+option java_package = "map_test"; |
+option java_outer_classname = "MapInitializationOrderTest"; |
+option java_multiple_files = true; |
-message TestOptimizedForSize { |
- optional int32 i = 1; |
- optional ForeignMessage msg = 19; |
+// Mirrors the structure of |
+// javatests/com/google/cloud/common/logging/logging_test.proto. |
+message Message1 { |
+ map<string, bool> map_field = 1; |
extensions 1000 to max; |
- |
- extend TestOptimizedForSize { |
- optional int32 test_extension = 1234; |
- optional TestRequiredOptimizedForSize test_extension2 = 1235; |
- } |
} |
-message TestRequiredOptimizedForSize { |
- required int32 x = 1; |
+extend Message1 { |
+ optional Message1 recursive_extension = 1001; |
} |
- |
-message TestOptionalOptimizedForSize { |
- optional TestRequiredOptimizedForSize o = 1; |
+ |
+message RedactAllTypes { |
} |