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 2022/08/12 08:15:16 UTC

[GitHub] [kafka] vamossagar12 commented on a diff in pull request #12502: KAFKA-14162: HoistField SMT should not return an immutable map for schemaless key/value

vamossagar12 commented on code in PR #12502:
URL: https://github.com/apache/kafka/pull/12502#discussion_r944222388


##########
connect/transforms/src/test/java/org/apache/kafka/connect/transforms/HoistFieldTest.java:
##########
@@ -58,4 +59,17 @@ public void withSchema() {
         assertEquals(42, ((Struct) transformedRecord.key()).get("magic"));
     }
 
+    @Test
+    public void testSchemalessMapIsMutable() {
+        xform.configure(Collections.singletonMap("field", "magic"));
+
+        final SinkRecord record = new SinkRecord("test", 0, null, 420, null, null, 0);
+        final SinkRecord transformedRecord = xform.apply(record);
+
+        assertNull(transformedRecord.keySchema());
+        @SuppressWarnings("unchecked")
+        Map<String, Object> key = (Map<String, Object>) transformedRecord.key();
+        key.put("k", "v");

Review Comment:
   nit: Probably wrap this put operation in `assertDoesNotThrow` to ensure `UnsupportedOperation` is not thrown? Something like => assertDoesNotThrow(() -> key.put("k", "v"));



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