leventov commented on a change in pull request #8808: use copy-on-write list in 
InMemoryAppender
URL: https://github.com/apache/incubator-druid/pull/8808#discussion_r342202395
 
 

 ##########
 File path: 
core/src/test/java/org/apache/druid/testing/junit/LoggerCaptureRule.java
 ##########
 @@ -78,12 +77,13 @@ public void clearLogEvents()
   {
     static final String NAME = InMemoryAppender.class.getName();
 
-    private final List<LogEvent> logEvents;
+    // need copy-on-write collection for thread safety of iteration and 
modification concurrently outside of a critical section
 
 Review comment:
   This comment doesn't achieve its goal: to help somebody to see why the 
enclosing class needs to be thread-safe. With the current comment, in order to 
do that, the reader (developer) should invoke "Find usages" IDE action and 
analyze these usages carefully. This is time-consuming. In essence, there 
should be concurrent access documentation, as described in 
https://github.com/code-review-checklists/java-concurrency#justify-document.
   
   This comment is also misleading because there are no critical sections in 
this code.

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


With regards,
Apache Git Services

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

Reply via email to