This repository was archived by the owner on Jan 23, 2020. It is now read-only.
Catch NPE when item.getInQueueSince() is unavailable#127
Merged
Conversation
truthbk
reviewed
Nov 5, 2018
truthbk
left a comment
Member
There was a problem hiding this comment.
Looks good, just a generic question and a note regarding the log level.
|
|
||
| // Send waiting metric if item.getInQueueSince() is available | ||
| try { | ||
| builddata.put("waiting", (System.currentTimeMillis() - item.getInQueueSince()) / DatadogBuildListener.THOUSAND_LONG); |
Member
There was a problem hiding this comment.
Man, the docs are pretty poor.... Do we know if the NPE comes from item being NULL (I would presume so) or is it being thrown by getInQueueSince()?
Contributor
Author
There was a problem hiding this comment.
It's not clear to me, I have a stack track showing the error thrown when calling item.getInQueueSince(), but not totally sure (the plugin version used in this stack trace corresponds to the line computing the waiting metric).
WARNING hudson.model.listeners.RunListener report
RunListener failed
java.lang.NullPointerException
at org.datadog.jenkins.plugins.datadog.DatadogBuildListener.onStarted(DatadogBuildListener.java:113)
at hudson.model.listeners.RunListener.fireStarted(RunListener.java:240)
at hudson.maven.MavenBuild$ProxyImpl2.start(MavenBuild.java:609)
at sun.reflect.GeneratedMethodAccessor981.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at hudson.model.Executor$2.call(Executor.java:912)
at hudson.util.InterceptingProxy$1.invoke(InterceptingProxy.java:23)
at com.sun.proxy.$Proxy89.start(Unknown Source)
at sun.reflect.GeneratedMethodAccessor981.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:929)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:903)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:855)
at hudson.remoting.UserRequest.perform(UserRequest.java:212)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:369)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at org.jenkinsci.remoting.CallableDecorator.call(CallableDecorator.java:19)
at hudson.remoting.CallableDecoratorList$1.call(CallableDecoratorList.java:21)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When computing the
jenkins.job.waitingmetric we callitem.getInQueueSince(). This may raise aNullPointerException, as seen with the ec2-spot-jenkins-plugin. This PR catches the NPE and skips sending the gauge metric.