You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Fokko (via GitHub)" <gi...@apache.org> on 2024/02/12 15:03:15 UTC

[PR] Support nested lists/maps in BlockingDirectBinaryEncoder [avro]

Fokko opened a new pull request, #2732:
URL: https://github.com/apache/avro/pull/2732

   <!--
   
   *Thank you very much for contributing to Apache Avro - we are happy that you want to help us improve Avro. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Avro a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/AVRO/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "AVRO-XXXX: [component] Title of the pull request", where *AVRO-XXXX* should be replaced by the actual issue number. 
       The *component* is optional, but can help identify the correct reviewers faster: either the language ("java", "python") or subsystem such as "build" or "doc" are good candidates.  
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests. You can [build the entire project](https://github.com/apache/avro/blob/main/BUILD.md) or just the [language-specific SDK](https://avro.apache.org/project/how-to-contribute/#unit-tests).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Every commit message references Jira issues in their subject lines. In addition, commits follow the guidelines from [How to write a good git commit message](https://chris.beams.io/posts/git-commit/)
       1. Subject is separated from body by a blank line
       1. Subject is limited to 50 characters (not including Jira issue reference)
       1. Subject does not end with a period
       1. Subject uses the imperative mood ("add", not "adding")
       1. Body wraps at 72 characters
       1. Body explains "what" and "why", not "how"
   
   -->
   
   ## What is the purpose of the change
   
   *(For example: This pull request improves file read performance by buffering data, fixing AVRO-XXXX.)*
   
   
   ## Verifying this change
   
   *(Please pick one of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
   - *Extended interop tests to verify consistent valid schema names between SDKs*
   - *Added test that validates that Java throws an AvroRuntimeException on invalid binary data*
   - *Manually verified the change by building the website and checking the new redirect*
   
   
   ## Documentation
   
   - Does this pull request introduce a new feature? (yes / no)
   - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AVRO-3871: Support nested lists/maps in BlockingDirectBinaryEncoder [avro]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko merged PR #2732:
URL: https://github.com/apache/avro/pull/2732


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AVRO-3871: Support nested lists/maps in BlockingDirectBinaryEncoder [avro]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #2732:
URL: https://github.com/apache/avro/pull/2732#issuecomment-2094945515

   Thanks @jbonofre 🙌 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] AVRO-3871: Support nested lists/maps in BlockingDirectBinaryEncoder [avro]

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #2732:
URL: https://github.com/apache/avro/pull/2732#discussion_r1486354435


##########
lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithMapsAndArrays.java:
##########
@@ -429,77 +583,193 @@
     out.writeMapStart();
     out.setItemCount(size1);
     long actualSize1 = 0;
-    for (java.util.Map.Entry<java.lang.String, java.lang.Long> e1 : this.map.entrySet()) {
+    for (java.util.Map.Entry<String, Long> e1 : this.map.entrySet()) {
       actualSize1++;
       out.startItem();
       out.writeString(e1.getKey());
-      java.lang.Long v1 = e1.getValue();
+      Long v1 = e1.getValue();
       out.writeLong(v1);
     }
     out.writeMapEnd();
     if (actualSize1 != size1)
       throw new java.util.ConcurrentModificationException(
           "Map-size written was " + size1 + ", but element count was " + actualSize1 + ".");
 
+    long size2 = this.nested_arr.size();
+    out.writeArrayStart();
+    out.setItemCount(size2);
+    long actualSize2 = 0;
+    for (java.util.List<String> e2 : this.nested_arr) {
+      actualSize2++;
+      out.startItem();
+      long size3 = e2.size();
+      out.writeArrayStart();
+      out.setItemCount(size3);
+      long actualSize3 = 0;
+      for (String e3 : e2) {
+        actualSize3++;
+        out.startItem();
+        out.writeString(e3);
+      }
+      out.writeArrayEnd();
+      if (actualSize3 != size3)
+        throw new java.util.ConcurrentModificationException(
+            "Array-size written was " + size3 + ", but element count was " + actualSize3 + ".");
+    }
+    out.writeArrayEnd();
+    if (actualSize2 != size2)
+      throw new java.util.ConcurrentModificationException(
+          "Array-size written was " + size2 + ", but element count was " + actualSize2 + ".");
+
+    long size4 = this.nested_map.size();
+    out.writeMapStart();
+    out.setItemCount(size4);
+    long actualSize4 = 0;
+    for (java.util.Map.Entry<String, java.util.Map<String, Long>> e4 : this.nested_map.entrySet()) {
+      actualSize4++;
+      out.startItem();
+      out.writeString(e4.getKey());
+      java.util.Map<String, Long> v4 = e4.getValue();
+      long size5 = v4.size();
+      out.writeMapStart();
+      out.setItemCount(size5);
+      long actualSize5 = 0;
+      for (java.util.Map.Entry<String, Long> e5 : v4.entrySet()) {
+        actualSize5++;
+        out.startItem();
+        out.writeString(e5.getKey());
+        Long v5 = e5.getValue();
+        out.writeLong(v5);
+      }
+      out.writeMapEnd();
+      if (actualSize5 != size5)
+        throw new java.util.ConcurrentModificationException(
+            "Map-size written was " + size5 + ", but element count was " + actualSize5 + ".");
+    }
+    out.writeMapEnd();
+    if (actualSize4 != size4)
+      throw new java.util.ConcurrentModificationException(
+          "Map-size written was " + size4 + ", but element count was " + actualSize4 + ".");
+
   }
 
   @Override
   public void customDecode(org.apache.avro.io.ResolvingDecoder in) throws java.io.IOException {
     org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
     if (fieldOrder == null) {
       long size0 = in.readArrayStart();
-      java.util.List<java.lang.String> a0 = this.arr;
+      java.util.List<String> a0 = this.arr;
       if (a0 == null) {
-        a0 = new SpecificData.Array<java.lang.String>((int) size0, SCHEMA$.getField("arr").schema());
+        a0 = new SpecificData.Array<String>((int) size0, SCHEMA$.getField("arr").schema());
         this.arr = a0;
       } else
         a0.clear();
-      SpecificData.Array<java.lang.String> ga0 = (a0 instanceof SpecificData.Array
-          ? (SpecificData.Array<java.lang.String>) a0
-          : null);
+      SpecificData.Array<String> ga0 = (a0 instanceof SpecificData.Array ? (SpecificData.Array<String>) a0 : null);

Review Comment:
   ## Cast from abstract to concrete collection
   
   [List<String>](1) is cast to the concrete type [Array<String>](2), losing abstraction.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3178)



##########
lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithMapsAndArrays.java:
##########
@@ -429,77 +583,193 @@
     out.writeMapStart();
     out.setItemCount(size1);
     long actualSize1 = 0;
-    for (java.util.Map.Entry<java.lang.String, java.lang.Long> e1 : this.map.entrySet()) {
+    for (java.util.Map.Entry<String, Long> e1 : this.map.entrySet()) {
       actualSize1++;
       out.startItem();
       out.writeString(e1.getKey());
-      java.lang.Long v1 = e1.getValue();
+      Long v1 = e1.getValue();
       out.writeLong(v1);
     }
     out.writeMapEnd();
     if (actualSize1 != size1)
       throw new java.util.ConcurrentModificationException(
           "Map-size written was " + size1 + ", but element count was " + actualSize1 + ".");
 
+    long size2 = this.nested_arr.size();
+    out.writeArrayStart();
+    out.setItemCount(size2);
+    long actualSize2 = 0;
+    for (java.util.List<String> e2 : this.nested_arr) {
+      actualSize2++;
+      out.startItem();
+      long size3 = e2.size();
+      out.writeArrayStart();
+      out.setItemCount(size3);
+      long actualSize3 = 0;
+      for (String e3 : e2) {
+        actualSize3++;
+        out.startItem();
+        out.writeString(e3);
+      }
+      out.writeArrayEnd();
+      if (actualSize3 != size3)
+        throw new java.util.ConcurrentModificationException(
+            "Array-size written was " + size3 + ", but element count was " + actualSize3 + ".");
+    }
+    out.writeArrayEnd();
+    if (actualSize2 != size2)
+      throw new java.util.ConcurrentModificationException(
+          "Array-size written was " + size2 + ", but element count was " + actualSize2 + ".");
+
+    long size4 = this.nested_map.size();
+    out.writeMapStart();
+    out.setItemCount(size4);
+    long actualSize4 = 0;
+    for (java.util.Map.Entry<String, java.util.Map<String, Long>> e4 : this.nested_map.entrySet()) {
+      actualSize4++;
+      out.startItem();
+      out.writeString(e4.getKey());
+      java.util.Map<String, Long> v4 = e4.getValue();
+      long size5 = v4.size();
+      out.writeMapStart();
+      out.setItemCount(size5);
+      long actualSize5 = 0;
+      for (java.util.Map.Entry<String, Long> e5 : v4.entrySet()) {
+        actualSize5++;
+        out.startItem();
+        out.writeString(e5.getKey());
+        Long v5 = e5.getValue();
+        out.writeLong(v5);
+      }
+      out.writeMapEnd();
+      if (actualSize5 != size5)
+        throw new java.util.ConcurrentModificationException(
+            "Map-size written was " + size5 + ", but element count was " + actualSize5 + ".");
+    }
+    out.writeMapEnd();
+    if (actualSize4 != size4)
+      throw new java.util.ConcurrentModificationException(
+          "Map-size written was " + size4 + ", but element count was " + actualSize4 + ".");
+
   }
 
   @Override
   public void customDecode(org.apache.avro.io.ResolvingDecoder in) throws java.io.IOException {
     org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
     if (fieldOrder == null) {
       long size0 = in.readArrayStart();
-      java.util.List<java.lang.String> a0 = this.arr;
+      java.util.List<String> a0 = this.arr;
       if (a0 == null) {
-        a0 = new SpecificData.Array<java.lang.String>((int) size0, SCHEMA$.getField("arr").schema());
+        a0 = new SpecificData.Array<String>((int) size0, SCHEMA$.getField("arr").schema());
         this.arr = a0;
       } else
         a0.clear();
-      SpecificData.Array<java.lang.String> ga0 = (a0 instanceof SpecificData.Array
-          ? (SpecificData.Array<java.lang.String>) a0
-          : null);
+      SpecificData.Array<String> ga0 = (a0 instanceof SpecificData.Array ? (SpecificData.Array<String>) a0 : null);
       for (; 0 < size0; size0 = in.arrayNext()) {
         for (; size0 != 0; size0--) {
-          java.lang.String e0 = (ga0 != null ? ga0.peek() : null);
+          String e0 = (ga0 != null ? ga0.peek() : null);
           e0 = in.readString();
           a0.add(e0);
         }
       }
 
       long size1 = in.readMapStart();
-      java.util.Map<java.lang.String, java.lang.Long> m1 = this.map; // Need fresh name due to limitation of macro
-                                                                     // system
+      java.util.Map<String, Long> m1 = this.map; // Need fresh name due to limitation of macro system
       if (m1 == null) {
-        m1 = new java.util.HashMap<java.lang.String, java.lang.Long>((int) size1);
+        m1 = new java.util.HashMap<String, Long>((int) size1);
         this.map = m1;
       } else
         m1.clear();
       for (; 0 < size1; size1 = in.mapNext()) {
         for (; size1 != 0; size1--) {
-          java.lang.String k1 = null;
+          String k1 = null;
           k1 = in.readString();
-          java.lang.Long v1 = null;
+          Long v1 = null;
           v1 = in.readLong();
           m1.put(k1, v1);
         }
       }
 
+      long size2 = in.readArrayStart();
+      java.util.List<java.util.List<String>> a2 = this.nested_arr;
+      if (a2 == null) {
+        a2 = new SpecificData.Array<java.util.List<String>>((int) size2, SCHEMA$.getField("nested_arr").schema());
+        this.nested_arr = a2;
+      } else
+        a2.clear();
+      SpecificData.Array<java.util.List<String>> ga2 = (a2 instanceof SpecificData.Array
+          ? (SpecificData.Array<java.util.List<String>>) a2
+          : null);
+      for (; 0 < size2; size2 = in.arrayNext()) {
+        for (; size2 != 0; size2--) {
+          java.util.List<String> e2 = (ga2 != null ? ga2.peek() : null);
+          long size3 = in.readArrayStart();
+          java.util.List<String> a3 = e2;
+          if (a3 == null) {
+            a3 = new SpecificData.Array<String>((int) size3, SCHEMA$.getField("nested_arr").schema().getElementType());
+            e2 = a3;
+          } else
+            a3.clear();
+          SpecificData.Array<String> ga3 = (a3 instanceof SpecificData.Array ? (SpecificData.Array<String>) a3 : null);
+          for (; 0 < size3; size3 = in.arrayNext()) {
+            for (; size3 != 0; size3--) {
+              String e3 = (ga3 != null ? ga3.peek() : null);
+              e3 = in.readString();
+              a3.add(e3);
+            }
+          }
+          a2.add(e2);
+        }
+      }
+
+      long size4 = in.readMapStart();
+      java.util.Map<String, java.util.Map<String, Long>> m4 = this.nested_map; // Need fresh name due to limitation of
+                                                                               // macro system
+      if (m4 == null) {
+        m4 = new java.util.HashMap<String, java.util.Map<String, Long>>((int) size4);
+        this.nested_map = m4;
+      } else
+        m4.clear();
+      for (; 0 < size4; size4 = in.mapNext()) {
+        for (; size4 != 0; size4--) {
+          String k4 = null;
+          k4 = in.readString();
+          java.util.Map<String, Long> v4 = null;
+          long size5 = in.readMapStart();
+          java.util.Map<String, Long> m5 = v4; // Need fresh name due to limitation of macro system
+          if (m5 == null) {
+            m5 = new java.util.HashMap<String, Long>((int) size5);
+            v4 = m5;
+          } else
+            m5.clear();
+          for (; 0 < size5; size5 = in.mapNext()) {
+            for (; size5 != 0; size5--) {
+              String k5 = null;
+              k5 = in.readString();
+              Long v5 = null;
+              v5 = in.readLong();
+              m5.put(k5, v5);
+            }
+          }
+          m4.put(k4, v4);
+        }
+      }
+
     } else {
-      for (int i = 0; i < 2; i++) {
+      for (int i = 0; i < 4; i++) {
         switch (fieldOrder[i].pos()) {
         case 0:
           long size0 = in.readArrayStart();
-          java.util.List<java.lang.String> a0 = this.arr;
+          java.util.List<String> a0 = this.arr;
           if (a0 == null) {
-            a0 = new SpecificData.Array<java.lang.String>((int) size0, SCHEMA$.getField("arr").schema());
+            a0 = new SpecificData.Array<String>((int) size0, SCHEMA$.getField("arr").schema());
             this.arr = a0;
           } else
             a0.clear();
-          SpecificData.Array<java.lang.String> ga0 = (a0 instanceof SpecificData.Array
-              ? (SpecificData.Array<java.lang.String>) a0
-              : null);
+          SpecificData.Array<String> ga0 = (a0 instanceof SpecificData.Array ? (SpecificData.Array<String>) a0 : null);

Review Comment:
   ## Cast from abstract to concrete collection
   
   [List<String>](1) is cast to the concrete type [Array<String>](2), losing abstraction.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3181)



##########
lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithMapsAndArrays.java:
##########
@@ -429,77 +583,193 @@
     out.writeMapStart();
     out.setItemCount(size1);
     long actualSize1 = 0;
-    for (java.util.Map.Entry<java.lang.String, java.lang.Long> e1 : this.map.entrySet()) {
+    for (java.util.Map.Entry<String, Long> e1 : this.map.entrySet()) {
       actualSize1++;
       out.startItem();
       out.writeString(e1.getKey());
-      java.lang.Long v1 = e1.getValue();
+      Long v1 = e1.getValue();
       out.writeLong(v1);
     }
     out.writeMapEnd();
     if (actualSize1 != size1)
       throw new java.util.ConcurrentModificationException(
           "Map-size written was " + size1 + ", but element count was " + actualSize1 + ".");
 
+    long size2 = this.nested_arr.size();
+    out.writeArrayStart();
+    out.setItemCount(size2);
+    long actualSize2 = 0;
+    for (java.util.List<String> e2 : this.nested_arr) {
+      actualSize2++;
+      out.startItem();
+      long size3 = e2.size();
+      out.writeArrayStart();
+      out.setItemCount(size3);
+      long actualSize3 = 0;
+      for (String e3 : e2) {
+        actualSize3++;
+        out.startItem();
+        out.writeString(e3);
+      }
+      out.writeArrayEnd();
+      if (actualSize3 != size3)
+        throw new java.util.ConcurrentModificationException(
+            "Array-size written was " + size3 + ", but element count was " + actualSize3 + ".");
+    }
+    out.writeArrayEnd();
+    if (actualSize2 != size2)
+      throw new java.util.ConcurrentModificationException(
+          "Array-size written was " + size2 + ", but element count was " + actualSize2 + ".");
+
+    long size4 = this.nested_map.size();
+    out.writeMapStart();
+    out.setItemCount(size4);
+    long actualSize4 = 0;
+    for (java.util.Map.Entry<String, java.util.Map<String, Long>> e4 : this.nested_map.entrySet()) {
+      actualSize4++;
+      out.startItem();
+      out.writeString(e4.getKey());
+      java.util.Map<String, Long> v4 = e4.getValue();
+      long size5 = v4.size();
+      out.writeMapStart();
+      out.setItemCount(size5);
+      long actualSize5 = 0;
+      for (java.util.Map.Entry<String, Long> e5 : v4.entrySet()) {
+        actualSize5++;
+        out.startItem();
+        out.writeString(e5.getKey());
+        Long v5 = e5.getValue();
+        out.writeLong(v5);
+      }
+      out.writeMapEnd();
+      if (actualSize5 != size5)
+        throw new java.util.ConcurrentModificationException(
+            "Map-size written was " + size5 + ", but element count was " + actualSize5 + ".");
+    }
+    out.writeMapEnd();
+    if (actualSize4 != size4)
+      throw new java.util.ConcurrentModificationException(
+          "Map-size written was " + size4 + ", but element count was " + actualSize4 + ".");
+
   }
 
   @Override
   public void customDecode(org.apache.avro.io.ResolvingDecoder in) throws java.io.IOException {
     org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
     if (fieldOrder == null) {
       long size0 = in.readArrayStart();
-      java.util.List<java.lang.String> a0 = this.arr;
+      java.util.List<String> a0 = this.arr;
       if (a0 == null) {
-        a0 = new SpecificData.Array<java.lang.String>((int) size0, SCHEMA$.getField("arr").schema());
+        a0 = new SpecificData.Array<String>((int) size0, SCHEMA$.getField("arr").schema());
         this.arr = a0;
       } else
         a0.clear();
-      SpecificData.Array<java.lang.String> ga0 = (a0 instanceof SpecificData.Array
-          ? (SpecificData.Array<java.lang.String>) a0
-          : null);
+      SpecificData.Array<String> ga0 = (a0 instanceof SpecificData.Array ? (SpecificData.Array<String>) a0 : null);
       for (; 0 < size0; size0 = in.arrayNext()) {
         for (; size0 != 0; size0--) {
-          java.lang.String e0 = (ga0 != null ? ga0.peek() : null);
+          String e0 = (ga0 != null ? ga0.peek() : null);
           e0 = in.readString();
           a0.add(e0);
         }
       }
 
       long size1 = in.readMapStart();
-      java.util.Map<java.lang.String, java.lang.Long> m1 = this.map; // Need fresh name due to limitation of macro
-                                                                     // system
+      java.util.Map<String, Long> m1 = this.map; // Need fresh name due to limitation of macro system
       if (m1 == null) {
-        m1 = new java.util.HashMap<java.lang.String, java.lang.Long>((int) size1);
+        m1 = new java.util.HashMap<String, Long>((int) size1);
         this.map = m1;
       } else
         m1.clear();
       for (; 0 < size1; size1 = in.mapNext()) {
         for (; size1 != 0; size1--) {
-          java.lang.String k1 = null;
+          String k1 = null;
           k1 = in.readString();
-          java.lang.Long v1 = null;
+          Long v1 = null;
           v1 = in.readLong();
           m1.put(k1, v1);
         }
       }
 
+      long size2 = in.readArrayStart();
+      java.util.List<java.util.List<String>> a2 = this.nested_arr;
+      if (a2 == null) {
+        a2 = new SpecificData.Array<java.util.List<String>>((int) size2, SCHEMA$.getField("nested_arr").schema());
+        this.nested_arr = a2;
+      } else
+        a2.clear();
+      SpecificData.Array<java.util.List<String>> ga2 = (a2 instanceof SpecificData.Array
+          ? (SpecificData.Array<java.util.List<String>>) a2

Review Comment:
   ## Cast from abstract to concrete collection
   
   [List<List<String>>](1) is cast to the concrete type [Array<List<String>>](2), losing abstraction.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3179)



##########
lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithMapsAndArrays.java:
##########
@@ -508,24 +778,94 @@
 
         case 1:
           long size1 = in.readMapStart();
-          java.util.Map<java.lang.String, java.lang.Long> m1 = this.map; // Need fresh name due to limitation of macro
-                                                                         // system
+          java.util.Map<String, Long> m1 = this.map; // Need fresh name due to limitation of macro system
           if (m1 == null) {
-            m1 = new java.util.HashMap<java.lang.String, java.lang.Long>((int) size1);
+            m1 = new java.util.HashMap<String, Long>((int) size1);
             this.map = m1;
           } else
             m1.clear();
           for (; 0 < size1; size1 = in.mapNext()) {
             for (; size1 != 0; size1--) {
-              java.lang.String k1 = null;
+              String k1 = null;
               k1 = in.readString();
-              java.lang.Long v1 = null;
+              Long v1 = null;
               v1 = in.readLong();
               m1.put(k1, v1);
             }
           }
           break;
 
+        case 2:
+          long size2 = in.readArrayStart();
+          java.util.List<java.util.List<String>> a2 = this.nested_arr;
+          if (a2 == null) {
+            a2 = new SpecificData.Array<java.util.List<String>>((int) size2, SCHEMA$.getField("nested_arr").schema());
+            this.nested_arr = a2;
+          } else
+            a2.clear();
+          SpecificData.Array<java.util.List<String>> ga2 = (a2 instanceof SpecificData.Array
+              ? (SpecificData.Array<java.util.List<String>>) a2

Review Comment:
   ## Cast from abstract to concrete collection
   
   [List<List<String>>](1) is cast to the concrete type [Array<List<String>>](2), losing abstraction.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3182)



##########
lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithMapsAndArrays.java:
##########
@@ -508,24 +778,94 @@
 
         case 1:
           long size1 = in.readMapStart();
-          java.util.Map<java.lang.String, java.lang.Long> m1 = this.map; // Need fresh name due to limitation of macro
-                                                                         // system
+          java.util.Map<String, Long> m1 = this.map; // Need fresh name due to limitation of macro system
           if (m1 == null) {
-            m1 = new java.util.HashMap<java.lang.String, java.lang.Long>((int) size1);
+            m1 = new java.util.HashMap<String, Long>((int) size1);
             this.map = m1;
           } else
             m1.clear();
           for (; 0 < size1; size1 = in.mapNext()) {
             for (; size1 != 0; size1--) {
-              java.lang.String k1 = null;
+              String k1 = null;
               k1 = in.readString();
-              java.lang.Long v1 = null;
+              Long v1 = null;
               v1 = in.readLong();
               m1.put(k1, v1);
             }
           }
           break;
 
+        case 2:
+          long size2 = in.readArrayStart();
+          java.util.List<java.util.List<String>> a2 = this.nested_arr;
+          if (a2 == null) {
+            a2 = new SpecificData.Array<java.util.List<String>>((int) size2, SCHEMA$.getField("nested_arr").schema());
+            this.nested_arr = a2;
+          } else
+            a2.clear();
+          SpecificData.Array<java.util.List<String>> ga2 = (a2 instanceof SpecificData.Array
+              ? (SpecificData.Array<java.util.List<String>>) a2
+              : null);
+          for (; 0 < size2; size2 = in.arrayNext()) {
+            for (; size2 != 0; size2--) {
+              java.util.List<String> e2 = (ga2 != null ? ga2.peek() : null);
+              long size3 = in.readArrayStart();
+              java.util.List<String> a3 = e2;
+              if (a3 == null) {
+                a3 = new SpecificData.Array<String>((int) size3,
+                    SCHEMA$.getField("nested_arr").schema().getElementType());
+                e2 = a3;
+              } else
+                a3.clear();
+              SpecificData.Array<String> ga3 = (a3 instanceof SpecificData.Array ? (SpecificData.Array<String>) a3

Review Comment:
   ## Cast from abstract to concrete collection
   
   [List<String>](1) is cast to the concrete type [Array<String>](2), losing abstraction.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3183)



##########
lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithMapsAndArrays.java:
##########
@@ -429,77 +583,193 @@
     out.writeMapStart();
     out.setItemCount(size1);
     long actualSize1 = 0;
-    for (java.util.Map.Entry<java.lang.String, java.lang.Long> e1 : this.map.entrySet()) {
+    for (java.util.Map.Entry<String, Long> e1 : this.map.entrySet()) {
       actualSize1++;
       out.startItem();
       out.writeString(e1.getKey());
-      java.lang.Long v1 = e1.getValue();
+      Long v1 = e1.getValue();
       out.writeLong(v1);
     }
     out.writeMapEnd();
     if (actualSize1 != size1)
       throw new java.util.ConcurrentModificationException(
           "Map-size written was " + size1 + ", but element count was " + actualSize1 + ".");
 
+    long size2 = this.nested_arr.size();
+    out.writeArrayStart();
+    out.setItemCount(size2);
+    long actualSize2 = 0;
+    for (java.util.List<String> e2 : this.nested_arr) {
+      actualSize2++;
+      out.startItem();
+      long size3 = e2.size();
+      out.writeArrayStart();
+      out.setItemCount(size3);
+      long actualSize3 = 0;
+      for (String e3 : e2) {
+        actualSize3++;
+        out.startItem();
+        out.writeString(e3);
+      }
+      out.writeArrayEnd();
+      if (actualSize3 != size3)
+        throw new java.util.ConcurrentModificationException(
+            "Array-size written was " + size3 + ", but element count was " + actualSize3 + ".");
+    }
+    out.writeArrayEnd();
+    if (actualSize2 != size2)
+      throw new java.util.ConcurrentModificationException(
+          "Array-size written was " + size2 + ", but element count was " + actualSize2 + ".");
+
+    long size4 = this.nested_map.size();
+    out.writeMapStart();
+    out.setItemCount(size4);
+    long actualSize4 = 0;
+    for (java.util.Map.Entry<String, java.util.Map<String, Long>> e4 : this.nested_map.entrySet()) {
+      actualSize4++;
+      out.startItem();
+      out.writeString(e4.getKey());
+      java.util.Map<String, Long> v4 = e4.getValue();
+      long size5 = v4.size();
+      out.writeMapStart();
+      out.setItemCount(size5);
+      long actualSize5 = 0;
+      for (java.util.Map.Entry<String, Long> e5 : v4.entrySet()) {
+        actualSize5++;
+        out.startItem();
+        out.writeString(e5.getKey());
+        Long v5 = e5.getValue();
+        out.writeLong(v5);
+      }
+      out.writeMapEnd();
+      if (actualSize5 != size5)
+        throw new java.util.ConcurrentModificationException(
+            "Map-size written was " + size5 + ", but element count was " + actualSize5 + ".");
+    }
+    out.writeMapEnd();
+    if (actualSize4 != size4)
+      throw new java.util.ConcurrentModificationException(
+          "Map-size written was " + size4 + ", but element count was " + actualSize4 + ".");
+
   }
 
   @Override
   public void customDecode(org.apache.avro.io.ResolvingDecoder in) throws java.io.IOException {
     org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
     if (fieldOrder == null) {
       long size0 = in.readArrayStart();
-      java.util.List<java.lang.String> a0 = this.arr;
+      java.util.List<String> a0 = this.arr;
       if (a0 == null) {
-        a0 = new SpecificData.Array<java.lang.String>((int) size0, SCHEMA$.getField("arr").schema());
+        a0 = new SpecificData.Array<String>((int) size0, SCHEMA$.getField("arr").schema());
         this.arr = a0;
       } else
         a0.clear();
-      SpecificData.Array<java.lang.String> ga0 = (a0 instanceof SpecificData.Array
-          ? (SpecificData.Array<java.lang.String>) a0
-          : null);
+      SpecificData.Array<String> ga0 = (a0 instanceof SpecificData.Array ? (SpecificData.Array<String>) a0 : null);
       for (; 0 < size0; size0 = in.arrayNext()) {
         for (; size0 != 0; size0--) {
-          java.lang.String e0 = (ga0 != null ? ga0.peek() : null);
+          String e0 = (ga0 != null ? ga0.peek() : null);
           e0 = in.readString();
           a0.add(e0);
         }
       }
 
       long size1 = in.readMapStart();
-      java.util.Map<java.lang.String, java.lang.Long> m1 = this.map; // Need fresh name due to limitation of macro
-                                                                     // system
+      java.util.Map<String, Long> m1 = this.map; // Need fresh name due to limitation of macro system
       if (m1 == null) {
-        m1 = new java.util.HashMap<java.lang.String, java.lang.Long>((int) size1);
+        m1 = new java.util.HashMap<String, Long>((int) size1);
         this.map = m1;
       } else
         m1.clear();
       for (; 0 < size1; size1 = in.mapNext()) {
         for (; size1 != 0; size1--) {
-          java.lang.String k1 = null;
+          String k1 = null;
           k1 = in.readString();
-          java.lang.Long v1 = null;
+          Long v1 = null;
           v1 = in.readLong();
           m1.put(k1, v1);
         }
       }
 
+      long size2 = in.readArrayStart();
+      java.util.List<java.util.List<String>> a2 = this.nested_arr;
+      if (a2 == null) {
+        a2 = new SpecificData.Array<java.util.List<String>>((int) size2, SCHEMA$.getField("nested_arr").schema());
+        this.nested_arr = a2;
+      } else
+        a2.clear();
+      SpecificData.Array<java.util.List<String>> ga2 = (a2 instanceof SpecificData.Array
+          ? (SpecificData.Array<java.util.List<String>>) a2
+          : null);
+      for (; 0 < size2; size2 = in.arrayNext()) {
+        for (; size2 != 0; size2--) {
+          java.util.List<String> e2 = (ga2 != null ? ga2.peek() : null);
+          long size3 = in.readArrayStart();
+          java.util.List<String> a3 = e2;
+          if (a3 == null) {
+            a3 = new SpecificData.Array<String>((int) size3, SCHEMA$.getField("nested_arr").schema().getElementType());
+            e2 = a3;
+          } else
+            a3.clear();
+          SpecificData.Array<String> ga3 = (a3 instanceof SpecificData.Array ? (SpecificData.Array<String>) a3 : null);

Review Comment:
   ## Cast from abstract to concrete collection
   
   [List<String>](1) is cast to the concrete type [Array<String>](2), losing abstraction.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3180)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org