Fixes NullPointerException that occurs in Scala Native when forking 10K fibers, as reported in #9681.
When running the PromiseSpec - waiter stack safety test on Scala Native, which forks 10,000 fibers, a NullPointerException is thrown in WeakConcurrentBag.addToLongTermStorage. The root cause is that Scala Native’s ConcurrentHashMap.newKeySet() has concurrency issues under high stress scenarios.
Replace ConcurrentHashMap.newKeySet with Collections.synchronizedSet(new HashSet) in the Scala Native-specific PlatformSpecific.scala. This provides thread-safe set operations without the concurrency bugs present in Scala Native’s ConcurrentHashMap implementation.
core/native/src/main/scala/zio/internal/PlatformSpecific.scala: Modified newConcurrentSet methods to use synchronized HashSet instead of ConcurrentHashMap.newKeySet()This fix should allow the PromiseSpec - waiter stack safety test to pass on Scala Native without throwing NullPointerException.
Fixes #9681
/claim #9681
Erichhhhhcat
@Erichhhhhcat
ZIO
@ZIO