-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Description
The method ReflectionSupport.findNestedClasses is not thread-safe because the underlying implementation uses a static field of type HashSet without any synchronization:
https://github.com/junit-team/junit5/blob/ed3d84d0db3807ae4065221c47d10448ea60e74b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java#L133
It should probably use ConcurrentHashMap.newKeySet() or similar. The question is also how much value this cache adds in the first place, but you probably had your reasons to introduce it.
Steps to reproduce
I cannot provide example code to show the non-thread-safety, because, as often with thread-safety issues, showcasing that something is not thread-safe is difficult.
In this particular case it can most likely result in arbitrary exceptions being thrown when two or more threads try to rehash the set at the same time.
Context
- Used versions (Jupiter/Vintage/Platform): 5.8.0