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 2021/04/09 09:30:18 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #10163: Add Thread.currentThread.interrupt() after catching InterruptedException and document it in the javadoc

eolivelli commented on a change in pull request #10163:
URL: https://github.com/apache/pulsar/pull/10163#discussion_r610484938



##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
##########
@@ -453,6 +455,7 @@ public UnAckedMessageTracker getUnAckedMessageTracker() {
         try {
             return internalBatchReceiveAsync().get();
         } catch (InterruptedException | ExecutionException e) {
+            Thread.currentThread().interrupt();

Review comment:
       no, we have to call "Thread.currentThread().interrupt()" only while catching InterruptedException.
   
   I suggest you to add some Util method and use it everywhere, this way we can still use multi catch
   
   ```
   public static void handleInterruptedException(Throwable t) {
        if (t instanceof InterruptedException) {
              Thread.currentThread().interrupt();     
       }
   }
   ```




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org