I'm trying for the first time to use a worker with...
# dependency-management
t
I'm trying for the first time to use a worker with classloader isolation. Of course I immediately hit a `NoClassDefFoundError`:
Copy code
java.lang.NoClassDefFoundError: io/netty/channel/group/ChannelMatchers
        at io.netty.channel.group.DefaultChannelGroup.close(DefaultChannelGroup.java:221)
it's unclear how this could happen because
DefaultChannelGroup
is not only present in the same jar but also the same package as the class that can't be found. My current best guess is that it has something to do with the fact that
ChannelMatchers
is accessed via a static member? Like so:
Copy code
@Override
public ChannelGroupFuture close() {
    return close(ChannelMatchers.all()); // NoClassDefFoundError
}
and it does appear as if there may be another version of this class on a classpath. I can see for example that my IDE has indexed two separate versions of this
io.netty:netty-transport
dependency (4.1.34.Final and 4.1.68.Final). So maybe the JVM can't find the class because another version of it has already been loaded by a related classloader? What's the relationship between the worker's (so-called "isolated") classloader and other classloaders? There are like 10 in the chain.
interesting, the build no longer fails when I use
processIsolation()
instead
yay, days without classpath pollution: 0
e
that's curious. I just printed out
((URLClassLoader)getClass().getClassLoader()).getURLs()
in a simple plugin that I have. the top-level classloader has is no differences between
classLoaderIsolation
and
processIsolation
, containing what I set in the spec
classpath
and my plugin, and the parents of each are identical (up to re-ordering), containing just Gradle and its dependencies.
t
this is a more complex project, but I was also surprised at the number of classloaders involved