Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException: Cannot get property 'status' on null object #409

Closed
embee1981 opened this issue Jul 16, 2020 · 4 comments
Closed

Comments

@embee1981
Copy link

On running dependencyUpdates using version 0.28.0 of the plugin I am getting the following exception. This happens against my companies Nexus server which has various uploads (in a bad state it seems) that only contain

maven-metadata.xml.md5
maven-metadata.xml.sha1

Apologies for the bad formatting, I've attached the full log
Log.txt

Caused by: java.lang.NullPointerException: Cannot get property 'status' on null object at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60) at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:190) at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:46)
Caused by: java.lang.NullPointerException: Cannot get property 'status' on null object

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:298)
at com.github.benmanes.gradle.versions.updates.Resolver$_addRevisionFilter_closure7$_closure14$_closure15.doCall(Resolver.groovy:173)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:37)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:135)
at com.github.benmanes.gradle.versions.updates.Resolver$_addRevisionFilter_closure7$_closure14$_closure17.doCall(Resolver.groovy:180)`
@embee1981
Copy link
Author

Log.txt

@ben-manes
Copy link
Owner

Since it depends on your Nexus server, unfortunately you'll need to do some sleuthing in our code. The NPE is in the following method when trying to call metadata.status,

private void addRevisionFilter(Configuration configuration, String revision) {
configuration.resolutionStrategy { ResolutionStrategy componentSelection ->
componentSelection.componentSelection { rules ->
def revisionFilter = { ComponentSelection selection, ComponentMetadata metadata ->
boolean accepted =
((revision == 'release') && (metadata.status == 'release')) ||
((revision == 'milestone') && (metadata.status != 'integration')) ||
(revision == 'integration') || (selection.candidate.version == 'none')
if (!accepted) {
selection.reject("Component status ${metadata.status} rejected by revision ${revision}")
}
}
rules.all ComponentSelection.methods.any { it.name == 'getMetadata' } ? { revisionFilter(it, it.metadata) } : revisionFilter
}
}
}

Can you try adding a null check and rerun?.

boolean accepted = (metadata == null) ||
    ((revision == 'release') && (metadata.status == 'release')) ||
    ((revision == 'milestone') && (metadata.status != 'integration')) ||
    (revision == 'integration') || (selection.candidate.version == 'none')

If you bump up the version in build.gradle and run gradle install, it should be published into your mavenLocal() repository. If you include that in your project's build and update the plugin version, it should resolve to the local jar and allow you to test locally. If it looks good, we can merge that fix and release for you.

@embee1981
Copy link
Author

Thanks for the quick response :-) That fix did the trick, no more exceptions and its able to resolve the dependencies now in our Nexus repo.

@ben-manes
Copy link
Owner

Kicked off the release (via CI). For some reason the sync from jcenter to gradle's plugin repository takes a few hours, but would certainly be live by tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants