Skip to content

Commit

Permalink
AVRO-265: Protocol.toJson writes null namespace (apache#1638)
Browse files Browse the repository at this point in the history
This change fixes this cosmetic bug.
  • Loading branch information
opwvhk authored Apr 13, 2022
1 parent fee1a73 commit 7673e8d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
25 changes: 13 additions & 12 deletions lang/java/avro/src/main/java/org/apache/avro/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -417,7 +416,9 @@ void toJson(JsonGenerator gen) throws IOException {

gen.writeStartObject();
gen.writeStringField("protocol", name);
gen.writeStringField("namespace", namespace);
if (namespace != null) {
gen.writeStringField("namespace", namespace);
}

if (doc != null)
gen.writeStringField("doc", doc);
Expand Down
1 change: 0 additions & 1 deletion lang/java/compiler/src/test/idl/output/reservedwords.avpr
Original file line number Diff line number Diff line change
@@ -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 applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.",
"types" : [ ],
"messages" : {
Expand Down
1 change: 0 additions & 1 deletion lang/java/compiler/src/test/idl/output/unicode.avpr
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 7673e8d

Please sign in to comment.