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_r257818590
########## 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: However, I was wrong, there is no possibility for a Thread leak, `delayedCloseExecutor` should exit anyway. But I don't see a point in moving `closed = true;` statement to the end of the method either. If you disagree perhaps you could open an issue for aligning to the same practice (`closed = true` in the end) across all Druid classes. If more people support support this stance then appropriate changes could be made. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org