Github user nickwallen commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/381#discussion_r90467298
  
    --- Diff: 
metron-platform/metron-test-utilities/src/main/java/org/apache/metron/test/mock/MockHTable.java
 ---
    @@ -437,15 +463,14 @@ public ResultScanner getScanner(byte[] family, byte[] 
qualifier)
         return getScanner(scan);
       }
     
    -  List<Put> putLog = new ArrayList<>();
    --- End diff --
    
    Good that we're digging into this.  I'm not totally sure that this is 
thread-safe.  You may be right.  I have used `memoize` for a thread-safe, 
lazy-loading cache.  That's the use case I've seen others use it for.  But 
maybe with that hammer, everything is looking like a nail to me. :)
    
    But in my opinion if `memoize` is not thread-safe, then `synchronizedList` 
is not either.  See the code snippets below.  What `synchronizedList` is doing 
seems to be a subset of what `memoize` does.  No?
    
    ```
        MemoizingSupplier(Supplier<T> delegate) {
          this.delegate = delegate;
        }
    
        public T get() {
          if(!this.initialized) {
            synchronized(this) {
              if(!this.initialized) {
                Object t = this.delegate.get();
                this.value = t;
                this.initialized = true;
                return t;
              }
            }
          }
    
          return this.value;
        }
      }
    ```
    
    versus
    
    ```
        ThreadSafeSupplier(Supplier<T> delegate) {
          this.delegate = delegate;
        }
    
        public T get() {
          Supplier var1 = this.delegate;
          synchronized(this.delegate) {
            return this.delegate.get();
          }
        }
      }
    ```


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to