You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/01/07 18:22:53 UTC

[GitHub] lovelle closed pull request #3314: Improvement and bug fixes for notify pending received calls

lovelle closed pull request #3314: Improvement and bug fixes for notify pending received calls
URL: https://github.com/apache/pulsar/pull/3314
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
index 648afb891e..9969da8522 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
@@ -909,28 +909,28 @@ void messageReceived(MessageIdData messageId, int redeliveryCount, ByteBuf heade
      *
      * @param message
      */
-    void notifyPendingReceivedCallback(final Message<T> message, Exception exception) {
-        if (!pendingReceives.isEmpty()) {
-            // fetch receivedCallback from queue
-            CompletableFuture<Message<T>> receivedFuture = pendingReceives.poll();
-            if (exception == null) {
-                checkNotNull(message, "received message can't be null");
-                if (receivedFuture != null) {
-                    if (conf.getReceiverQueueSize() == 0) {
-                        // return message to receivedCallback
-                        receivedFuture.complete(message);
-                    } else {
-                        // increase permits for available message-queue
-                        Message<T> interceptMsg = beforeConsume(message);
-                        messageProcessed(interceptMsg);
-                        // return message to receivedCallback
-                        listenerExecutor.execute(() -> receivedFuture.complete(interceptMsg));
-                    }
-                }
-            } else {
-                listenerExecutor.execute(() -> receivedFuture.completeExceptionally(exception));
-            }
+    private void notifyPendingReceivedCallback(final Message<T> message, Exception exception) {
+        if (pendingReceives.isEmpty()) {
+            return;
+        }
+
+        checkNotNull(message, "received message can't be null");
+        // fetch receivedCallback from queue
+        CompletableFuture<Message<T>> receivedFuture = pendingReceives.poll();
+        if (exception != null) {
+            receivedFuture.completeExceptionally(exception);
+            return;
         }
+
+        if (conf.getReceiverQueueSize() == 0) {
+            receivedFuture.complete(beforeConsume(message));
+            return;
+        }
+
+        // increase permits for available message-queue
+        messageProcessed(message);
+        // return message to receivedCallback
+        receivedFuture.complete(beforeConsume(message));
     }
 
     private void triggerZeroQueueSizeListener(final Message<T> message) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services