congbobo184 commented on code in PR #15061:
URL: https://github.com/apache/pulsar/pull/15061#discussion_r845061819


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TopicTransactionBufferRecoverTest.java:
##########
@@ -569,4 +570,52 @@ public void testTransactionBufferNoSnapshotCloseReader() 
throws Exception{
         assertTrue(stats.getSubscriptions().keySet().contains("__compaction"));
     }
 
+    @Test
+    public void transactionBufferRecoverFailRemoveProducerFuture() throws 
Exception {
+        String topic = NAMESPACE1 + 
"/transactionBufferRecoverFailRemoveProducerFuture";
+
+        @Cleanup
+        Producer<byte[]> producer = pulsarClient
+                .newProducer()
+                .topic(topic)
+                .sendTimeout(0, TimeUnit.SECONDS)
+                .create();
+
+
+        // txn buffer init success
+        Transaction txn = pulsarClient.newTransaction()
+                .withTransactionTimeout(5, TimeUnit.SECONDS)
+                .build().get();
+        producer.newMessage(txn).value("test".getBytes()).sendAsync();
+        producer.newMessage(txn).value("test".getBytes()).sendAsync();
+        txn.commit().get();
+
+        PersistentTopic originalTopic = (PersistentTopic) 
getPulsarServiceList().get(0)
+                .getBrokerService().getTopic(TopicName.get(topic).toString(), 
false).get().get();
+        TopicTransactionBuffer topicTransactionBuffer = 
(TopicTransactionBuffer) originalTopic.getTransactionBuffer();
+
+        CompletableFuture<Void> bufferFuture = new CompletableFuture<>();
+        bufferFuture.completeExceptionally(new 
BrokerServiceException.ServiceUnitNotReadyException("test"));
+
+        // set fail future to topic transaction buffer
+        Field field = 
TopicTransactionBuffer.class.getDeclaredField("transactionBufferFuture");
+        field.setAccessible(true);
+        field.set(topicTransactionBuffer, bufferFuture);

Review Comment:
   cool!



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