You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/04/13 19:08:16 UTC

[avro] branch branch-1.11 updated: AVRO-265: Protocol.toJson writes null namespace (#1638)

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/branch-1.11 by this push:
     new c673f643a AVRO-265: Protocol.toJson writes null namespace (#1638)
c673f643a is described below

commit c673f643ab3284c2b40a73c94447d1e2a2aaa14f
Author: Oscar Westra van Holthe - Kind <op...@users.noreply.github.com>
AuthorDate: Wed Apr 13 21:07:44 2022 +0200

    AVRO-265: Protocol.toJson writes null namespace (#1638)
    
    This change fixes this cosmetic bug.
    
    (cherry picked from commit 7673e8da822a9e27d7ff3e6258f91e2369b9f620)
---
 .../src/main/java/org/apache/avro/Protocol.java    | 25 +++++++++++-----------
 .../src/test/idl/output/reservedwords.avpr         |  1 -
 .../java/compiler/src/test/idl/output/unicode.avpr |  1 -
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/lang/java/avro/src/main/java/org/apache/avro/Protocol.java b/lang/java/avro/src/main/java/org/apache/avro/Protocol.java
index 914beb8e8..ff9968895 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/Protocol.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/Protocol.java
@@ -17,30 +17,29 @@
  */
 package org.apache.avro;
 
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.avro.Schema.Field;
+import org.apache.avro.Schema.Field.Order;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
-import java.io.IOException;
 import java.security.MessageDigest;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.Set;
-import java.util.HashSet;
-
-import org.apache.avro.Schema.Field;
-import org.apache.avro.Schema.Field.Order;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
 
 /**
  * A set of messages forming an application protocol.
@@ -417,7 +416,9 @@ public class Protocol extends JsonProperties {
 
     gen.writeStartObject();
     gen.writeStringField("protocol", name);
-    gen.writeStringField("namespace", namespace);
+    if (namespace != null) {
+      gen.writeStringField("namespace", namespace);
+    }
 
     if (doc != null)
       gen.writeStringField("doc", doc);
diff --git a/lang/java/compiler/src/test/idl/output/reservedwords.avpr b/lang/java/compiler/src/test/idl/output/reservedwords.avpr
index 96f5b0feb..f28a90cc8 100644
--- a/lang/java/compiler/src/test/idl/output/reservedwords.avpr
+++ b/lang/java/compiler/src/test/idl/output/reservedwords.avpr
@@ -1,6 +1,5 @@
 {
   "protocol" : "Foo",
-  "namespace" : null,
   "doc" : "Licensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by [...]
   "types" : [ ],
   "messages" : {
diff --git a/lang/java/compiler/src/test/idl/output/unicode.avpr b/lang/java/compiler/src/test/idl/output/unicode.avpr
index 67642e218..c58a04300 100644
--- a/lang/java/compiler/src/test/idl/output/unicode.avpr
+++ b/lang/java/compiler/src/test/idl/output/unicode.avpr
@@ -1,6 +1,5 @@
 {
   "protocol" : "Протоколы",
-  "namespace" : null,
   "doc" : "This is a test that UTF8 functions correctly.\nこのテストでは、UTF - 8で正しく機能している。\n这是一个测试,UTF - 8的正常运行。",
   "types" : [ {
     "type" : "record",