[ https://issues.apache.org/jira/browse/KAFKA-3956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15373134#comment-15373134 ]
Gavin Manning commented on KAFKA-3956: -------------------------------------- {{monospaced}} {noformat} @Test public void testErrorNextAfterSend() { final MockProducer<String, byte[]> mockProducer = new MockProducer<>(false, new StringSerializer(), new ByteArraySerializer()); byte[] bytes = new byte[10]; final ProducerRecord<String, byte[]> record = new ProducerRecord<>("topic", "key", bytes); Assert.assertTrue(mockProducer.history().isEmpty()); mockProducer.send(record); // History should be empty ... but isn't Assert.assertTrue(mockProducer.history().isEmpty()); // Cause the next operation to fail Assert.assertTrue(mockProducer.errorNext(new RuntimeException("Force an error"))); System.out.println("Mock producer contains " + mockProducer.history().size() + " message(s)"); // We're too late ... the message has already been "sent" Assert.assertTrue(mockProducer.history().isEmpty()); } {noformat} {{monospaced}} > MockProducer.send() sends a message before completeNext() or errorNext() are > called > ----------------------------------------------------------------------------------- > > Key: KAFKA-3956 > URL: https://issues.apache.org/jira/browse/KAFKA-3956 > Project: Kafka > Issue Type: Bug > Components: producer > Affects Versions: 0.10.0.0 > Environment: JUnit test > Reporter: Gavin Manning > > I pass false for autoComplete to MockProducer's constructor. > I then call MockProducer.send(). > MockProducer.history() now contains that message. > I would expect completeNext() to cause the message to be added to history and > errorNext() to *not* add the message to history. -- This message was sent by Atlassian JIRA (v6.3.4#6332)