NPE in DefaultPeristentDirectoryStore


(Justin Ryan) #1

When using GradleLauncher:

GradleLauncher launcher = GradleLauncher.newInstance(startParameter)

I’m unable to poke into any configurations (for my plugin integration tests), e.g.

launcher.run().gradle.getRootProject().getConfigurations().getByName('runtime').files

It results in an NPE:

org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':compile'.
 at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.wrapException(ErrorHandlingArtifactDependencyResolver.java:51)
 at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.access$000(ErrorHandlingArtifactDependencyResolver.java:29)
 at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver$ErrorHandlingResolvedConfiguration.getFiles(ErrorHandlingArtifactDependencyResolver.java:84)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:463)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:202)
 at org.gradle.api.internal.file.CompositeFileCollection.getFiles(CompositeFileCollection.java:39)
 at org.gradle.api.internal.file.AbstractFileCollection.iterator(AbstractFileCollection.java:60)
 at netflix.nebula.includeruntime.NebulaIncludeRuntimePluginLauncherTest.compile using transitive dependency(NebulaIncludeRuntimePluginLauncherTest.groovy:34)
Caused by: java.lang.NullPointerException
 at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:134)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:58)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.getFiles(DefaultLenientConfiguration.java:132)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.getFilesStrict(DefaultLenientConfiguration.java:104)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultResolvedConfiguration.getFiles(DefaultResolvedConfiguration.java:45)
 at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver$FilesAggregatingResolvedConfiguration.getFiles(SelfResolvingDependencyResolver.java:81)
 at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver$ErrorHandlingResolvedConfiguration.getFiles(ErrorHandlingArtifactDependencyResolver.java:82)
 ... 5 more

It looks like DefaultPersistentDirectoryStore is being called after it’s been closed. Is there anyway to have DefaultPersistentDirectoryStore open the cache if it’s closed? It seems to be naively calling cacheAccess, which can be null. This is with a snapshot of 1.7, but it doesn’t look like it’s fixed in master.


(Szczepan Faber) #2

Hey Justin!

GradleLauncher is deprecated so I don’t think we’ll fix this issue.

It looks like you’re resolving the configuration after the build has completed (e.g. after run() method has finished) and it isn’t really supported.

Hope that helps!


(Justin Ryan) #3

Fair enough. GradleLauncher is the only way to inspect the Gradle object after a build (Tooling API can’t do this) though. So it’s incredibly helpful in integration tests. Until some formal integration tests support is added, don’t be removing GradleLauncher just yet.

This use-case does point out some faults with DefaultPersistentDirectoryStore, which might need to be fixed when Gradle moves to being a long-running program (which doesn’t hog the cache while running).


(Szczepan Faber) #4

Thanks for feedback.

I hope we’ll add first class integration testing support soon.