Demogorgon314 commented on code in PR #16142:
URL: https://github.com/apache/pulsar/pull/16142#discussion_r901523556


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java:
##########
@@ -997,6 +1000,48 @@ public void testConsistencyOfTransactionStatsAtEndTxn() 
throws Exception {
         transaction.commit().get();
     }
 
+    @Test
+    public void testGetConnectExceptionForAckMsgWhenCnxIsNull() throws 
Exception {
+        String topic = NAMESPACE1 + 
"/testGetConnectExceptionForAckMsgWhenCnxIsNull";
+        @Cleanup
+        Producer<byte[]> producer = pulsarClient
+                .newProducer(Schema.BYTES)
+                .topic(topic)
+                .sendTimeout(0, TimeUnit.SECONDS)
+                .create();
+
+        @Cleanup
+        Consumer<byte[]> consumer = pulsarClient
+                .newConsumer()
+                .topic(topic)
+                .subscriptionName("sub")
+                .subscribe();
+
+        for (int i = 0; i < 10; i++) {
+            producer.newMessage().value(Bytes.toBytes(i)).send();
+        }
+        Method method = ConsumerImpl.class.getDeclaredMethod("cnx");
+        method.setAccessible(true);
+        ClientCnx cnx = (ClientCnx) method.invoke(consumer);
+        Method method1 = 
ConsumerImpl.class.getDeclaredMethod("connectionClosed", ClientCnx.class);
+        method1.setAccessible(true);
+        method1.invoke(consumer, cnx);

Review Comment:
   ```suggestion
           ClientCnx cnx = Whitebox.invokeMethod(consumer, "cnx");
           Whitebox.invokeMethod(consumer, "connectionClosed", cnx);
   ```
   We can use `Whitebox` to simplify the reflect operation.



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