Skip to content

Commit

Permalink
[FIXED JENKINS-33201 Java JSON exception with an empty parametrized b…
Browse files Browse the repository at this point in the history
…uild.] (#2444)

* Fixed JENKINS-33201 [Java JSON exception with an empty parametrized
build.]

* FIXED JENKINS-33201. Changed to FormException instead of Failure

* That fix was never in a released version.

So it cannot have been reverted.

* Lowercase i for consistency

* Remove the concept of yanking dead executors.

* Another unnecessary call to doYank.

* [FIXED JENKINS-27530] Jenkins.reload must also reload the Queue to ensure that every Queue.Item.task corresponds to a live Job, lest nextBuildNumber be bogus.

* [JENKINS-27530] Noting #2439 & #2440.

* FIXED JENKINS-33201. Changed to FormException instead of Failure

* [FIXED JENKINS-33201 .FormException is thrown if parameterDefinitions are not available .

* Changing one more Tab to Space

* Moved checkForEmptyParameters to Job class
  • Loading branch information
rupinr authored and oleg-nenashev committed Jul 15, 2016
1 parent 4577cf6 commit 0b51770
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions core/src/main/java/hudson/model/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,8 @@ public synchronized void doConfigSubmit(StaplerRequest req,
DescribableList<JobProperty<?>, JobPropertyDescriptor> t = new DescribableList<JobProperty<?>, JobPropertyDescriptor>(NOOP,getAllProperties());
JSONObject jsonProperties = json.optJSONObject("properties");
if (jsonProperties != null) {
//This handles the situation when Parameterized build checkbox is checked but no parameters are selected. User will be redirected to an error page with proper error message.
Job.checkForEmptyParameters(jsonProperties);
t.rebuild(req,jsonProperties,JobPropertyDescriptor.getPropertyDescriptors(Job.this.getClass()));
} else {
t.clear();
Expand Down Expand Up @@ -1535,4 +1537,18 @@ public BuildTimelineWidget getTimeline() {
}

private final static HexStringConfidentialKey SERVER_COOKIE = new HexStringConfidentialKey(Job.class,"serverCookie",16);

/**
* This handles the situation when Parameterized build checkbox is checked
* but no parameters are selected. User will be redirected to an error page
* with proper error message.
* @param jsonProperties
* @throws FormException
*/
private static void checkForEmptyParameters(JSONObject jsonProperties) throws FormException{
JSONObject parameterDefinitionProperty = jsonProperties.getJSONObject("hudson-model-ParametersDefinitionProperty");
if ((parameterDefinitionProperty.getBoolean("specified") == true)&& !parameterDefinitionProperty.has("parameterDefinitions")) {
throw new FormException(Messages.Hudson_NoParamsSpecified(),"parameterDefinitions");
}
}
}
2 changes: 2 additions & 0 deletions core/src/main/resources/hudson/model/Messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,5 @@ Jenkins.IsRestarting=Jenkins is restarting

User.IllegalUsername="{0}" is prohibited as a username for security reasons.
User.IllegalFullname="{0}" is prohibited as a full name for security reasons.

Hudson.NoParamsSpecified=No Parameters are specified for this parameterized build
2 changes: 1 addition & 1 deletion core/src/main/resources/jenkins/model/Messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Hudson.NotUsesUTF8ToDecodeURL=\
See <a href="http://wiki.jenkins-ci.org/display/JENKINS/Containers">Containers</a> and \
<a href="http://wiki.jenkins-ci.org/display/JENKINS/Tomcat#Tomcat-i18n">Tomcat i18n</a> for more details.
Hudson.NodeDescription=the master Jenkins node

Hudson.NoParamsSpecified=No Parameters are specified for this parameterized build

CLI.restart.shortDescription=Restart Jenkins.
CLI.safe-restart.shortDescription=Safely restart Jenkins.
Expand Down

0 comments on commit 0b51770

Please sign in to comment.