You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/11/02 08:03:33 UTC
[GitHub] [incubator-druid] leventov commented on a change in pull request
#8808: use copy-on-write synchronized list in InMemoryAppender
leventov commented on a change in pull request #8808: use copy-on-write synchronized list in InMemoryAppender
URL: https://github.com/apache/incubator-druid/pull/8808#discussion_r341802826
##########
File path: core/src/test/java/org/apache/druid/testing/junit/LoggerCaptureRule.java
##########
@@ -94,7 +94,7 @@ public void append(LogEvent logEvent)
List<LogEvent> getLogEvents()
{
- return Collections.unmodifiableList(logEvents);
+ return Collections.synchronizedList(logEvents);
Review comment:
1) It's not copy-on-write (as the title of your PR says), it's `synchronizedList`, but this doesn't solve the problem: see https://github.com/code-review-checklists/java-concurrency#synchronized-collection-iter. However, if you actually use `CopyOnWriteArrayList` instead of `ArrayList` as `logEvents`, that would help. Don't forget to change the type of the field from `List<LogEvent>` to `CopyOnWriteArrayList<LogEvent>` and to add a comment explaining the need for synchronization, along the lines of https://github.com/code-review-checklists/java-concurrency#justify-document.
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org