Github user justinleet commented on a diff in the pull request:
    --- Diff: 
    @@ -437,15 +463,14 @@ public ResultScanner getScanner(byte[] family, byte[] 
         return getScanner(scan);
    -  List<Put> putLog = new ArrayList<>();
    --- End diff --
    Couldn't you just change this to
    ```List<Put> putLog = Collections. synchronizedList(new ArrayList<>());```?
    I'd still keep the `ImmutableList.copyOf()` in `getPutLog()`, because a 
synchronized list still requires a synchronized block during iteration and 
callers could do whatever.  Notably, `ImmutableList.copyOf()` specifically 
states "This method is safe to use even when elements is a synchronized or 
concurrent collection that is currently being modified by another thread."
    At that point, it should be thread-safe.  It doesn't expose the underlying 
list, the putLog doesn't get iterated over in this class, and it only exposes 
thread safe copies of the putLog.
    I'm also not convinced that the Supplier solution is actually thread-safe, 
which may be my own ignorance. The `get()` itself is thread-safe (per 
`memoize()`), but just returns a regular ArrayList (```this.putLog = 
Suppliers.memoize(() -> new ArrayList<Put>());```).  The `add()` won't 
necessarily be thread-safe, because two threads could each call `get()` and 
still attempt to put onto the same list at the same time. Assuming that's 
correct (which I'd like a second opinion on), it's probably just more that 
shuffling things happens to ease the race condition.
    Somebody feel free to hop in and correct any misconceptions I have here.  
I'm not as familiar with Java's concurrency as I probably (definitely?) should 

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

Reply via email to