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

[GitHub] [kafka] jsancio opened a new pull request, #13363: KAFKA-14794; Decode base64 JSON string

jsancio opened a new pull request, #13363:
URL: https://github.com/apache/kafka/pull/13363

   A binary value (array of bytes) can be a BinaryNode or a TextNode. When it is a BinaryNode, the method binaryValue() always returns non-null. When it is a TextNode, the method binaryValue() will return non-null if the value is a base64 string. For all other JSON nodes binaryValue returns null;
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


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


[GitHub] [kafka] jsancio merged pull request #13363: KAFKA-14794; Decode base64 JSON string

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


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


[GitHub] [kafka] cmccabe commented on a diff in pull request #13363: KAFKA-14794; Decode base64 JSON string

Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #13363:
URL: https://github.com/apache/kafka/pull/13363#discussion_r1129857640


##########
clients/src/test/java/org/apache/kafka/common/protocol/MessageUtilTest.java:
##########
@@ -83,4 +90,31 @@ public void testConstants() {
         assertEquals(MessageUtil.UNSIGNED_SHORT_MAX, 0xFFFF);
         assertEquals(MessageUtil.UNSIGNED_INT_MAX, 0xFFFFFFFFL);
     }
+
+    @Test
+    public void testBinaryNode() throws IOException {
+        byte[] expected = new byte[] {5, 2, 9, 4, 1, 8, 7, 0, 3, 6};
+        StringWriter writer = new StringWriter();
+        ObjectMapper mapper = new ObjectMapper();
+
+        mapper.writeTree(mapper.createGenerator(writer), new BinaryNode(expected));
+
+        JsonNode binaryNode = mapper.readTree(writer.toString());
+
+        assertTrue(binaryNode.isTextual(), binaryNode.toString());

Review Comment:
   can you make the assertion failure message a little bit clearer? Just printing the node seems a bit cryptic.



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


[GitHub] [kafka] jsancio commented on a diff in pull request #13363: KAFKA-14794; Decode base64 JSON string

Posted by "jsancio (via GitHub)" <gi...@apache.org>.
jsancio commented on code in PR #13363:
URL: https://github.com/apache/kafka/pull/13363#discussion_r1129947176


##########
clients/src/test/java/org/apache/kafka/common/protocol/MessageUtilTest.java:
##########
@@ -83,4 +90,31 @@ public void testConstants() {
         assertEquals(MessageUtil.UNSIGNED_SHORT_MAX, 0xFFFF);
         assertEquals(MessageUtil.UNSIGNED_INT_MAX, 0xFFFFFFFFL);
     }
+
+    @Test
+    public void testBinaryNode() throws IOException {
+        byte[] expected = new byte[] {5, 2, 9, 4, 1, 8, 7, 0, 3, 6};
+        StringWriter writer = new StringWriter();
+        ObjectMapper mapper = new ObjectMapper();
+
+        mapper.writeTree(mapper.createGenerator(writer), new BinaryNode(expected));
+
+        JsonNode binaryNode = mapper.readTree(writer.toString());
+
+        assertTrue(binaryNode.isTextual(), binaryNode.toString());

Review Comment:
   Fixed.



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