ljmcr commented on PR #100: URL: https://github.com/apache/openwebbeans/pull/100#issuecomment-2433808093
Hi, Thank you for the reply, Please ignore the previous mention of "parallel", which is not a correct analysis in this case. The issue is come from modifying the collection during iteration caused an ArrayIndexOutOfBoundsException, as the internal state of the IdentityHashMap (or other underlying data structures) became inconsistent when the iteration order changed unexpectedly. This error occurred because the original code implicitly relied on the collection being in a particular state while modifying it during iteration, an assumption that NonDex exposed as a bug. The original removeIf() method modified the collection during iteration, which is inherently risky when the collection's internal state may change (especially under NonDex). I have also tried to use the Iterator() for map as an alternate solution, but the errors still occurred when running with different seeds for multiple times. Using a hashset to collect all the elements to be removed is a better solution from my point of view, which ignore the dependency on iteration order and avoids modifying the map during iteration, also ensures that the code can handle randomized iteration order without throwing exceptions or causing inconsistent internal states. I am willing to discuss any other solutions and appreciate for any further feedbacks, thank you! > > Hi, Thank you for the response. The test failure occurs when running with different seed values using Nondex, not when running a single Nondex run multiple times. > > Hi! > > Seems nondex is a really cool tool for testing whether tests are really reliable. In this very case it creates a false positive though. The reason is that the whole CDI container is not intended to be started in parallel for the same application. Or rather for the same ClassLoader. This is the very core of a JavaEE/JakartaEE container and thus most parts are single threaded by definition. Probably there is some room for internal parallelisation but I fear removing from a list based on a single boolean is not helping much. The point is that OWB (as Spring and tons of other containers) does rely on basically a Map<ClassLoader, BeanManageImpl>. You CAN support running parallel tests, but then you have to do tricks like adding an intermediate ClassLoader (new URLClassLoader) like we did in a few specific tests and set this as TCCL for the thread. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@openwebbeans.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org