rich-c-shop commented on code in PR #17099:
URL: https://github.com/apache/kafka/pull/17099#discussion_r1828631651


##########
clients/src/test/java/org/apache/kafka/clients/producer/KafkaProducerTest.java:
##########
@@ -1099,6 +1104,28 @@ private <T extends Serializer<String>> void 
doTestHeaders(Class<T> serializerCla
         producer.close(Duration.ofMillis(0));
     }
 
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testHeadersFailure() {
+        Properties props = new Properties();
+        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9999");
+        props.put(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, 
ProducerInterceptorForHeaders.class.getName());
+        Serializer<String> keySerializer = mock(Serializer.class);
+        Serializer<String> valueSerializer = mock(Serializer.class);
+
+        KafkaProducer<String, String> producer = new KafkaProducer<>(props, 
keySerializer, valueSerializer);
+        ProducerRecord<String, String> record = new ProducerRecord<>("topic", 
"key", "value");
+        Future<RecordMetadata> future = producer.send(record, (recordMetadata, 
exception) -> { });
+        try {
+            assertInstanceOf(TimeoutException.class, 
assertThrows(ExecutionException.class, future::get).getCause());

Review Comment:
   yes, the test was slow and timeout after 1 min. I just add MAX_BLOCK_MS=500 
like other tests, it finish within 1s
   
   f2438262b4



##########
clients/src/test/java/org/apache/kafka/clients/producer/KafkaProducerTest.java:
##########
@@ -1099,6 +1104,28 @@ private <T extends Serializer<String>> void 
doTestHeaders(Class<T> serializerCla
         producer.close(Duration.ofMillis(0));
     }
 
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testHeadersFailure() {
+        Properties props = new Properties();
+        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9999");
+        props.put(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, 
ProducerInterceptorForHeaders.class.getName());
+        Serializer<String> keySerializer = mock(Serializer.class);
+        Serializer<String> valueSerializer = mock(Serializer.class);
+
+        KafkaProducer<String, String> producer = new KafkaProducer<>(props, 
keySerializer, valueSerializer);
+        ProducerRecord<String, String> record = new ProducerRecord<>("topic", 
"key", "value");
+        Future<RecordMetadata> future = producer.send(record, (recordMetadata, 
exception) -> { });
+        try {
+            assertInstanceOf(TimeoutException.class, 
assertThrows(ExecutionException.class, future::get).getCause());

Review Comment:
   addressed at f2438262b4



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to