[GRADLE-503] AbstractJettyRunTask throws NPE Created: 26/May/09  Updated: 04/Jan/13  Resolved: 28/May/09

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 0.6.1

Type: Bug
Reporter: Shanon McQuay Assignee: Hans Dockter
Resolution: Fixed Votes: 0


 Description   

Just ran into some trouble when upgrading gradle from 0.5.2 to 0.6.

I'm getting the following stack trace...

Caused by: org.gradle.api.GradleException: An error occurred starting the Jetty server.
at org.gradle.api.plugins.jetty.AbstractJettyRunTask.startJettyInternal(AbstractJettyRunTask.java:299)
at org.gradle.api.plugins.jetty.AbstractJettyRunTask.startJetty(AbstractJettyRunTask.java:232)
at org.gradle.api.plugins.jetty.AbstractJettyRunTask$1.execute(AbstractJettyRunTask.java:60)
at org.gradle.api.plugins.jetty.AbstractJettyRunTask$1.execute(AbstractJettyRunTask.java:47)
at org.gradle.api.internal.AbstractTask.doExecute(AbstractTask.java:219)
at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:174)
... 9 common frames omitted
Caused by: java.lang.NullPointerException
at org.gradle.api.plugins.jetty.AbstractJettyRunTask.startJettyInternal(AbstractJettyRunTask.java:281)
... 14 common frames omitted

I had a quick look at the code and my guess is that the following code is the culprit:

if (getStopPort() > 0 && getStopKey() != null) {
Monitor monitor = new Monitor(getStopPort(), getStopKey(), new Server[]

{(Server) server.getProxiedObject()}

, !daemon);
monitor.start();
}

This code will attempt to autobox the stop port to an int value but because the stop port is null by default (according to chapter 18.4 of the user guide) it can throw a NPE during autoboxing.

As I expected, adding the following line to my build.gradle stopped this NPE from occuring...

stopPort = 8081



 Comments   
Comment by Hans Dockter [ 28/May/09 ]

This should be fixed now. Could you give it a try?

Comment by Hans Dockter [ 28/May/09 ]

BTW: The Jetty plugin is more or less a port of the Maven Jetty plugin. Unfortunately the original code comes without unit test. We haven't come around to adding them yet.

Comment by Hans Dockter [ 28/May/09 ]

I have tried it myself. The bug is fixed. Thanks.

Comment by Shanon McQuay [ 28/May/09 ]

Fantastic. Thanks for the quick response, keep up the great work!

Generated at Wed Jun 30 11:31:45 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.