You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by GitBox <gi...@apache.org> on 2020/09/08 03:49:12 UTC

[GitHub] [avro] lukemin89 commented on a change in pull request #955: AVRO-2905: Fix Utf8 hash cache

lukemin89 commented on a change in pull request #955:
URL: https://github.com/apache/avro/pull/955#discussion_r484634769



##########
File path: lang/java/avro/src/main/java/org/apache/avro/util/Utf8.java
##########
@@ -119,16 +120,21 @@ public Utf8 setByteLength(int newLength) {
     }
     this.length = newLength;
     this.string = null;
-    this.hasHash = false;
+    this.hash = 0;
     return this;
   }
 
   /** Set to the contents of a String. */
   public Utf8 set(String string) {
-    this.bytes = getBytesFor(string);
-    this.length = bytes.length;
+    byte[] bytes = getBytesFor(string);
+    int length = bytes.length;
+    if (length > MAX_LENGTH) {
+      throw new AvroRuntimeException("String length " + length + " exceeds maximum allowed");
+    }

Review comment:
       Im not sure, but this seemed like a bug to me as well. 
   `MAX_LENGTH` should be kept at all time right?
   




----------------------------------------------------------------
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.

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