Hi!
We’re facing an issue on our CI servers while building a fairly large multi-project (around 500 projects), with parallel and configuration-on-demand both enabled. Sometimes, Gradle just hangs while running, and the moment when it hangs seems to be random… I couldn’t find any pattern 
You can have a look at the thread dump here: https://gist.github.com/Ithildir/8cc456669907a3527875. These parts are especially interesting:
"Task worker" prio=10 tid=0x096ef400 nid=0x7e14 runnable [0x073fd000]
java.lang.Thread.State: RUNNABLE
at java.util.WeakHashMap.get(WeakHashMap.java:471)
at org.apache.ivy.core.module.id.ModuleId.intern(ModuleId.java:63)
at org.apache.ivy.core.module.id.ModuleId.newInstance(ModuleId.java:48)
at org.gradle.api.internal.artifacts.ivyservice.IvyUtil.createModuleId(IvyUtil.java:79)
- locked <0x358744e8> (a java.lang.Object)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.PomReader$PomDependencyMgtElement.getExcludedModules(PomReader.java:529)
and
"Task worker Thread 2" prio=10 tid=0x096efc00 nid=0x7e15 waiting for monitor entry [0x071fd000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.gradle.api.internal.artifacts.ivyservice.IvyUtil.createModuleId(IvyUtil.java:78)
- waiting to lock <0x358744e8> (a java.lang.Object)
at org.gradle.api.internal.artifacts.ivyservice.moduleconverter.DefaultExcludeRuleConverter.createExcludeRule(DefaultExcludeRuleConverter.java:30)
It really looks like GRADLE-3027, which is marked as resolved. If I understand, you centralized all the calls to Ivy’s ModuleId.newInstance and ModuleRevisionId.newInstance in IvyUtil, so you could synchronize them and avoid the WeakHashMap bug. However, this line in GradlePomModuleDescriptorBuilder does not use IvyUtil. I did some debugging, and it seems that ModuleId.intern (which is not thread-safe) is only called from IvyUtil or from this Gradle class.
What do you think about it? For now, we’ll try to replace that call with IvyUtil and use a patched version.
Thank you! 
