You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/02/21 17:27:55 UTC

[GitHub] [kafka] sknop commented on a change in pull request #9950: KAFKA-12170: Fix for Connect Cast SMT to correctly transform a Byte array into a string

sknop commented on a change in pull request #9950:
URL: https://github.com/apache/kafka/pull/9950#discussion_r579838511



##########
File path: connect/transforms/src/main/java/org/apache/kafka/connect/transforms/Cast.java
##########
@@ -364,11 +365,24 @@ private static String castToString(Object value) {
         if (value instanceof java.util.Date) {
             java.util.Date dateValue = (java.util.Date) value;
             return Values.dateFormatFor(dateValue).format(dateValue);
+        } else if (value instanceof ByteBuffer) {
+            ByteBuffer byteBuffer = (ByteBuffer) value;
+            return castByteArrayToString(byteBuffer.array());

Review comment:
       That is a good point, but what should happen in that case? 
   
   I assume we start with hasArray() and only process the content if an array is available, as I understand it? ByteBuffer.remaining() would contain the number of bytes available ... I'll go and write some test cases to understand this better.




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