avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rskr...@apache.org
Subject [avro] branch master updated: AVRO-2691: Do Not Cache Empty Array in RecordBuilderBase (#771)
Date Mon, 17 Feb 2020 16:11:31 GMT
This is an automated email from the ASF dual-hosted git repository.

rskraba pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new a65dca9  AVRO-2691: Do Not Cache Empty Array in RecordBuilderBase (#771)
a65dca9 is described below

commit a65dca9bc4981b7788b51d3297323136e4f664ae
Author: belugabehr <12578579+belugabehr@users.noreply.github.com>
AuthorDate: Mon Feb 17 08:11:23 2020 -0800

    AVRO-2691: Do Not Cache Empty Array in RecordBuilderBase (#771)
---
 .../avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java   | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java b/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java
index 431733c..68a9edf 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java
@@ -29,7 +29,6 @@ import java.util.Arrays;
 
 /** Abstract base class for RecordBuilder implementations. Not thread-safe. */
 public abstract class RecordBuilderBase<T extends IndexedRecord> implements RecordBuilder<T>
{
-  private static final Field[] EMPTY_FIELDS = new Field[0];
   private final Schema schema;
   private final Field[] fields;
   private final boolean[] fieldSetFlags;
@@ -59,7 +58,7 @@ public abstract class RecordBuilderBase<T extends IndexedRecord> implements
Reco
   protected RecordBuilderBase(Schema schema, GenericData data) {
     this.schema = schema;
     this.data = data;
-    fields = schema.getFields().toArray(EMPTY_FIELDS);
+    fields = schema.getFields().toArray(new Field[0]);
     fieldSetFlags = new boolean[fields.length];
   }
 
@@ -72,7 +71,7 @@ public abstract class RecordBuilderBase<T extends IndexedRecord> implements
Reco
   protected RecordBuilderBase(RecordBuilderBase<T> other, GenericData data) {
     this.schema = other.schema;
     this.data = data;
-    fields = schema.getFields().toArray(EMPTY_FIELDS);
+    fields = schema.getFields().toArray(new Field[0]);
     fieldSetFlags = Arrays.copyOf(other.fieldSetFlags, other.fieldSetFlags.length);
   }
 


Mime
View raw message