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_r257009109
##########
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:
If it throws an exception once, it will likely throw it the second time as
well. I think the general practice is to set such flags up front and don't
allow to "close again" in case of errors. In user code, when close() throws an
exception, nobody tries to close an object again either.
----------------------------------------------------------------
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]