You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "divijvaidya (via GitHub)" <gi...@apache.org> on 2023/04/18 09:18:59 UTC

[GitHub] [kafka] divijvaidya commented on a diff in pull request #13582: MINOR: Fix lossy conversions flagged by Java 20

divijvaidya commented on code in PR #13582:
URL: https://github.com/apache/kafka/pull/13582#discussion_r1169714114


##########
clients/src/main/java/org/apache/kafka/common/record/CompressionType.java:
##########
@@ -128,11 +128,11 @@ public InputStream wrapForInput(ByteBuffer buffer, byte messageVersion, BufferSu
         }
     };
 
-    public final int id;
+    public final byte id;

Review Comment:
   please add a comment that in the schema for RecordBatch, the type is represented by 2 bits. Hence, byte representation is sufficient.



##########
clients/src/main/java/org/apache/kafka/common/record/DefaultRecordBatch.java:
##########
@@ -434,7 +434,7 @@ private static byte computeAttributes(CompressionType type, TimestampType timest
         if (isControl)
             attributes |= CONTROL_FLAG_MASK;
         if (type.id > 0)
-            attributes |= COMPRESSION_CODEC_MASK & type.id;
+            attributes |= (byte) (COMPRESSION_CODEC_MASK & type.id);

Review Comment:
   Do we still need this cast to byte? Both `COMPRESSION_CODEC_MASK` and `type.id` are bytes.



-- 
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: jira-unsubscribe@kafka.apache.org

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