-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
Jenkins v1.467; repo plugin v1.2.1
Steps to reproduce:
- Have a build job that uses the repo plugin
- Run that job where one or more projects were added/removed from the manifest
- Access that job through the Jenkins API
Behavior:
- Going directly to the build's page in Jenkins works as I expect. However, I'm using a script that accesses Jenkins through its API. When I tack on '/api/json' or '/api/xml' to the URL, I get the following exception:
Caused by: java.lang.NullPointerException
at hudson.plugins.repo.ChangeLogEntry$1.size(ChangeLogEntry.java:296)
at java.util.AbstractList$Itr.hasNext(AbstractList.java:339)
at org.kohsuke.stapler.export.Property.writeValue(Property.java:180)
at org.kohsuke.stapler.export.Property.writeValue(Property.java:136)
at org.kohsuke.stapler.export.Property.writeTo(Property.java:113)
at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:179)
at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176)
at org.kohsuke.stapler.export.Property.writeValue(Property.java:231)
at org.kohsuke.stapler.export.Property.writeValue(Property.java:168)
at org.kohsuke.stapler.export.Property.writeValue(Property.java:136)
at org.kohsuke.stapler.export.Property.writeTo(Property.java:113)
at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:179)
at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176)
at org.kohsuke.stapler.export.Property.writeValue(Property.java:231)
at org.kohsuke.stapler.export.Property.writeValue(Property.java:136)
at org.kohsuke.stapler.export.Property.writeTo(Property.java:113)
at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:179)
at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176)
at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176)
at org.kohsuke.stapler.export.Model.writeTo(Model.java:152)
at org.kohsuke.stapler.ResponseImpl.serveExposedBean(ResponseImpl.java:200)
at hudson.model.Api.doJson(Api.java:181)
at sun.reflect.GeneratedMethodAccessor980.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:288)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:151)
at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:90)
at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:203)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
at org.kohsuke.stapler.MetaClass$12.dispatch(MetaClass.java:384)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:241)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:488)
at org.kohsuke.stapler.Stapler.service(Stapler.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
Looking at the code (git rev 3fb046cc), I see line 296 is "return modifiedFiles.size()" in this method:
@Override
public Collection<String> getAffectedPaths() {
return new AbstractList<String>() {
@Override
public String get(final int index)
@Override
public int size()
};
}
If modifiedFiles is null, it would cause the behavior I'm seeing. In ChangeLog.java there appear to be 2 places where null is passed in as the modifiedFiles of ChangeLogEntry - lines 125 and 133, handling manifest adds and removals.
[JENKINS-14576] NullPointerException in hudson.plugins.repo.ChangeLogEntry when using Jenkins API
Description |
Original:
Steps to reproduce: - Have a build job that uses the repo plugin - Run that job such that it pulls down changes where one or more commits had no files changed (these seem to be merge commits in our case) - Access that job through the Jenkins API Behavior: - Going directly to the build's page in Jenkins works as I expect. However, I'm using a script that accesses Jenkins through its API. When I tack on '/api/json' or '/api/xml' to the URL, I get the following exception: Caused by: java.lang.NullPointerException at hudson.plugins.repo.ChangeLogEntry$1.size(ChangeLogEntry.java:296) at java.util.AbstractList$Itr.hasNext(AbstractList.java:339) at org.kohsuke.stapler.export.Property.writeValue(Property.java:180) at org.kohsuke.stapler.export.Property.writeValue(Property.java:136) at org.kohsuke.stapler.export.Property.writeTo(Property.java:113) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:179) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176) at org.kohsuke.stapler.export.Property.writeValue(Property.java:231) at org.kohsuke.stapler.export.Property.writeValue(Property.java:168) at org.kohsuke.stapler.export.Property.writeValue(Property.java:136) at org.kohsuke.stapler.export.Property.writeTo(Property.java:113) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:179) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176) at org.kohsuke.stapler.export.Property.writeValue(Property.java:231) at org.kohsuke.stapler.export.Property.writeValue(Property.java:136) at org.kohsuke.stapler.export.Property.writeTo(Property.java:113) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:179) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176) at org.kohsuke.stapler.export.Model.writeTo(Model.java:152) at org.kohsuke.stapler.ResponseImpl.serveExposedBean(ResponseImpl.java:200) at hudson.model.Api.doJson(Api.java:181) at sun.reflect.GeneratedMethodAccessor980.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:288) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:151) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:90) at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659) at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:203) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659) at org.kohsuke.stapler.MetaClass$12.dispatch(MetaClass.java:384) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659) at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:241) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:488) at org.kohsuke.stapler.Stapler.service(Stapler.java:162) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) Looking at the code (git rev 3fb046cc), I see line 296 is "return modifiedFiles.size()" in this method: @Override public Collection<String> getAffectedPaths() { return new AbstractList<String>() { @Override public String get(final int index) { return modifiedFiles.get(index).getPath(); } @Override public int size() { return modifiedFiles.size(); } }; } If modifiedFiles is null, it would cause the behavior I'm seeing. |
New:
Steps to reproduce: - Have a build job that uses the repo plugin - Run that job where one or more projects were added/removed from the manifest - Access that job through the Jenkins API Behavior: - Going directly to the build's page in Jenkins works as I expect. However, I'm using a script that accesses Jenkins through its API. When I tack on '/api/json' or '/api/xml' to the URL, I get the following exception: Caused by: java.lang.NullPointerException at hudson.plugins.repo.ChangeLogEntry$1.size(ChangeLogEntry.java:296) at java.util.AbstractList$Itr.hasNext(AbstractList.java:339) at org.kohsuke.stapler.export.Property.writeValue(Property.java:180) at org.kohsuke.stapler.export.Property.writeValue(Property.java:136) at org.kohsuke.stapler.export.Property.writeTo(Property.java:113) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:179) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176) at org.kohsuke.stapler.export.Property.writeValue(Property.java:231) at org.kohsuke.stapler.export.Property.writeValue(Property.java:168) at org.kohsuke.stapler.export.Property.writeValue(Property.java:136) at org.kohsuke.stapler.export.Property.writeTo(Property.java:113) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:179) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176) at org.kohsuke.stapler.export.Property.writeValue(Property.java:231) at org.kohsuke.stapler.export.Property.writeValue(Property.java:136) at org.kohsuke.stapler.export.Property.writeTo(Property.java:113) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:179) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176) at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:176) at org.kohsuke.stapler.export.Model.writeTo(Model.java:152) at org.kohsuke.stapler.ResponseImpl.serveExposedBean(ResponseImpl.java:200) at hudson.model.Api.doJson(Api.java:181) at sun.reflect.GeneratedMethodAccessor980.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:288) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:151) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:90) at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659) at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:203) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659) at org.kohsuke.stapler.MetaClass$12.dispatch(MetaClass.java:384) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659) at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:241) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:488) at org.kohsuke.stapler.Stapler.service(Stapler.java:162) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) Looking at the code (git rev 3fb046cc), I see line 296 is "return modifiedFiles.size()" in this method: @Override public Collection<String> getAffectedPaths() { return new AbstractList<String>() { @Override public String get(final int index) { return modifiedFiles.get(index).getPath(); } @Override public int size() { return modifiedFiles.size(); } }; } If modifiedFiles is null, it would cause the behavior I'm seeing. In ChangeLog.java there appear to be 2 places where null is passed in as the modifiedFiles of ChangeLogEntry - lines 125 and 133, handling manifest adds and removals. |
Workflow | Original: JNJira [ 145261 ] | New: JNJira + In-Review [ 176300 ] |