Hello Taher,

Taher Alkhateeb <[email protected]> writes:

> So just to make sure I understand this correctly, we're replacing the
> old synchronized block with a ConcurrentHashMap using the atomic
> function "computeIfAbsent" and then refactored the class loading logic
> into a separate method right?

That's correct. ‘ConcurrentHashMap::computeIfAbsent’ ensures that the
method invokation is done atomically [1].

> Given how critical this piece of code is, wouldn't it be more
> appropriate to introduce an integration test and apply it here? I
> didn't find any testing feedback on the JIRA.

Indeed being critical makes it desirable to provide a test.  However
concurrency issues are hardly testable in practice since the execution
order is nondeterministic.  I think we can't do better than reasoning
about the actual concurrency model.  Are you puzzled by a specific
scenario?

Thanks.

[1] 
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html#computeIfAbsent-K-java.util.function.Function-

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37

Reply via email to