leventov commented on a change in pull request #7038: Fix and document 
concurrency of EventReceiverFirehose and TimedShutoffFirehose; Refine 
concurrency specification of Firehose
URL: https://github.com/apache/incubator-druid/pull/7038#discussion_r257817128
 
 

 ##########
 File path: 
server/src/main/java/org/apache/druid/segment/realtime/firehose/EventReceiverFirehoseFactory.java
 ##########
 @@ -350,34 +427,45 @@ public long getBytesReceived()
       return bytesReceived.get();
     }
 
+    /**
+     * This method is synchronized because it might be called concurrently 
from multiple threads: from {@link
+     * #delayedCloseExecutor}, and explicitly on this Firehose object.
+     */
     @Override
-    public void close()
+    public synchronized void close()
     {
-      if (!closed) {
-        log.info("Firehose closing.");
-        closed = true;
+      if (closed) {
+        return;
+      }
+      closed = true;
 
 Review comment:
   I checked Druid sources (search `closed = true`) and it's a random mix of 
closing first and closing last. In `EventReceiverFirehose` closing last gives 
nothing but the possibility of a Thread leak (delayedCloseExecutor may not 
exit).

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to