[prev in list] [next in list] [prev in thread] [next in thread] 

List:       avro-commits
Subject:    [avro] 02/02: AVRO-2386: Make customEncode and customDecode public (#511)
From:       fokko () apache ! org
Date:       2019-05-07 18:26:06
Message-ID: 20190507182604.9C96B8728B () gitbox ! apache ! org
[Download RAW message or body]

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

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

commit 3c76495e9524ef322726d03d7ee406be89e8fde0
Author: Katrin Skoglund <katrin.skoglund@avanza.se>
AuthorDate: Tue May 7 20:23:40 2019 +0200

    AVRO-2386: Make customEncode and customDecode public (#511)
    
    * Make customEncode and customDecode methods public
    
    * Make methods in superclass public
    
    (cherry picked from commit e250dcc0ae0e3b32ce9d1cad0e9f580dbd241b15)
---
 .../apache/avro/specific/SpecificRecordBase.java   |  4 +--
 .../specific/templates/java/classic/record.vm      |  4 +--
 .../TestNestedRecordsWithDifferentNamespaces.java  | 34 ++++++++++++++++++++++
 .../avro/nested_records_different_namespace.avsc   | 23 +++++++++++++++
 .../avro/examples/baseball/Player.java             |  4 +--
 .../tools/src/test/compiler/output/Player.java     |  4 +--
 6 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificRecordBase.java \
b/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificRecordBase.java index \
                0084da0..1394dcb 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificRecordBase.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificRecordBase.java
@@ -115,11 +115,11 @@ public abstract class SpecificRecordBase
     return false;
   }
 
-  protected void customEncode(Encoder out) throws IOException {
+  public void customEncode(Encoder out) throws IOException {
     throw new UnsupportedOperationException();
   }
 
-  protected void customDecode(ResolvingDecoder in) throws IOException {
+  public void customDecode(ResolvingDecoder in) throws IOException {
     throw new UnsupportedOperationException();
   }
 }
diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm \
b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
 old mode 100644
new mode 100755
index 738ffac..ca9a131
--- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
                
+++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
 @@ -536,7 +536,7 @@ static {
 #if ($this.isCustomCodable($schema))
   @Override protected boolean hasCustomCoders() { return true; }
 
-  @Override protected void customEncode(org.apache.avro.io.Encoder out)
+  @Override public void customEncode(org.apache.avro.io.Encoder out)
     throws java.io.IOException
   {
 #set ($nv = 0)## Counter to ensure unique var-names
@@ -550,7 +550,7 @@ static {
 #end
   }
 
-  @Override protected void customDecode(org.apache.avro.io.ResolvingDecoder in)
+  @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
     throws java.io.IOException
   {
     org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
diff --git a/lang/java/integration-test/codegen-test/src/test/java/org/apache/avro/codegentest/TestNestedRecordsWithDifferentNamespaces.java \
b/lang/java/integration-test/codegen-test/src/test/java/org/apache/avro/codegentest/TestNestedRecordsWithDifferentNamespaces.java
 new file mode 100755
index 0000000..831de6a
--- /dev/null
+++ b/lang/java/integration-test/codegen-test/src/test/java/org/apache/avro/codegentest/TestNestedRecordsWithDifferentNamespaces.java
 @@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avro.codegentest;
+
+import org.apache.avro.codegentest.other.NestedOtherNamespaceRecord;
+import org.apache.avro.codegentest.some.NestedSomeNamespaceRecord;
+import org.junit.Test;
+
+public class TestNestedRecordsWithDifferentNamespaces extends \
AbstractSpecificRecordTest { +
+  @Test
+  public void testNestedRecordsWithDifferentNamespaces() {
+    NestedSomeNamespaceRecord instanceOfGeneratedClass = \
NestedSomeNamespaceRecord.newBuilder() +        \
.setNestedRecordBuilder(NestedOtherNamespaceRecord.newBuilder().setSomeField(1)).build();
 +    verifySerDeAndStandardMethods(instanceOfGeneratedClass);
+  }
+
+}
diff --git a/lang/java/integration-test/codegen-test/src/test/resources/avro/nested_records_different_namespace.avsc \
b/lang/java/integration-test/codegen-test/src/test/resources/avro/nested_records_different_namespace.avsc
 new file mode 100755
index 0000000..b5a8351
--- /dev/null
+++ b/lang/java/integration-test/codegen-test/src/test/resources/avro/nested_records_different_namespace.avsc
 @@ -0,0 +1,23 @@
+{"namespace": "org.apache.avro.codegentest.some",
+  "type": "record",
+  "name": "NestedSomeNamespaceRecord",
+  "doc" : "Test nested types with different namespace than the outer type",
+  "fields": [
+    {
+      "name": "nestedRecord",
+      "type": {
+        "namespace": "org.apache.avro.codegentest.other",
+        "type": "record",
+        "name": "NestedOtherNamespaceRecord",
+        "fields": [
+          {
+            "name": "someField",
+            "type": "int"
+          }
+        ]
+      }
+    }]
+}
+
+
+
diff --git a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java \
b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java \
                index bd373ac..697d590 100644
--- a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
                
+++ b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
 @@ -493,7 +493,7 @@ public class Player extends \
org.apache.avro.specific.SpecificRecordBase implemen  
   @Override protected boolean hasCustomCoders() { return true; }
 
-  @Override protected void customEncode(org.apache.avro.io.Encoder out)
+  @Override public void customEncode(org.apache.avro.io.Encoder out)
     throws java.io.IOException
   {
     out.writeInt(this.number);
@@ -517,7 +517,7 @@ public class Player extends \
org.apache.avro.specific.SpecificRecordBase implemen  
   }
 
-  @Override protected void customDecode(org.apache.avro.io.ResolvingDecoder in)
+  @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
     throws java.io.IOException
   {
     org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
diff --git a/lang/java/tools/src/test/compiler/output/Player.java \
b/lang/java/tools/src/test/compiler/output/Player.java index 642640c..e717d86 100644
--- a/lang/java/tools/src/test/compiler/output/Player.java
+++ b/lang/java/tools/src/test/compiler/output/Player.java
@@ -493,7 +493,7 @@ public class Player extends \
org.apache.avro.specific.SpecificRecordBase implemen  
   @Override protected boolean hasCustomCoders() { return true; }
 
-  @Override protected void customEncode(org.apache.avro.io.Encoder out)
+  @Override public void customEncode(org.apache.avro.io.Encoder out)
     throws java.io.IOException
   {
     out.writeInt(this.number);
@@ -517,7 +517,7 @@ public class Player extends \
org.apache.avro.specific.SpecificRecordBase implemen  
   }
 
-  @Override protected void customDecode(org.apache.avro.io.ResolvingDecoder in)
+  @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
     throws java.io.IOException
   {
     org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic