uap-java icon indicating copy to clipboard operation
uap-java copied to clipboard

CachingParser is not thread safe

Open gysel opened this issue 5 years ago • 2 comments

The class CachingParser uses a org.apache.commons.collections4.map.LRUMap internally.

The JavaDoc clearly states:

Note that LRUMap is not synchronized and is not thread-safe. If you wish to use this map from multiple threads concurrently, you must use appropriate synchronization. The simplest approach is to wrap this map using Collections.synchronizedMap(Map). This class may throw NullPointerException's when accessed by concurrent threads.

I think it would be good to add a lock directly in the CachingParser.

gysel avatar Jun 21 '19 13:06 gysel

related: https://github.com/ua-parser/uap-java/pull/24

gysel avatar Jun 24 '19 05:06 gysel

This would be appreciated. 👍

chriscarruthers avatar Aug 05 '20 08:08 chriscarruthers