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

[FIXED JENKINS-33201 Java JSON exception with an empty parametrized build.] #2444

Merged
merged 15 commits into from
Jul 15, 2016

Conversation

rupinr
Copy link
Contributor

@rupinr rupinr commented Jul 9, 2016

I have handled this issue gracefully. Now user will be redirected to an error page giving information about the error (Similar to how it is handled for empty job/view name)

image

.getJSONObject("hudson-model-ParametersDefinitionProperty");
if ((parameterDefinitionProperty.getBoolean("specified") == true)
&& !parameterDefinitionProperty.has("parameterDefinitions")) {
throw new Failure(Messages.Hudson_NoParamsSpecified());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should throw FormException at least

@oleg-nenashev oleg-nenashev added the needs-more-reviews Complex change, which would benefit from more eyes label Jul 9, 2016
@oleg-nenashev
Copy link
Member

I think it would be better to just ignore empty property instead of throwing exxceptions

@rupinr
Copy link
Contributor Author

rupinr commented Jul 10, 2016

I have changed to FormException. Please check now.

*/
public static void checkForEmptyParameters(JSONObject jsonProperties) throws FormException{
JSONObject parameterDefinitionProperty = jsonProperties
.getJSONObject("hudson-model-ParametersDefinitionProperty");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file uses tabs, not spaces

@oleg-nenashev
Copy link
Member

Seems you've rebased some master branch changes instead of merging them. Not a problem if we squash the PR during merging.

* @param jsonProperties
* @throws FormException
*/
public static void checkForEmptyParameters(JSONObject jsonProperties) throws FormException{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see this method as a part of public API (especially in the Jenkins class). There are hardcoded values for jobs only. Would be better to just inline this method to the code or to move it to a private method in the Job class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@rupinr
Copy link
Contributor Author

rupinr commented Jul 12, 2016

And regarding the comment "

Seems you've rebased some master branch changes instead of merging them. Not a problem if we squash the PR during merging.

Please squash these commits, so that my commits wont mess up the git log in master 👍

* 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the future. Please avoid using empty Javadoc definitions. Default Javadoc linting behavior in JDK8 considers it as an error

@oleg-nenashev
Copy link
Member

weak 👍 for merging with squash

@rupinr
Copy link
Contributor Author

rupinr commented Jul 12, 2016

weak 👍 for merging with squash
Do I need to resubmit my PR with a clean history?..

Just for the future. Please avoid using empty Javadoc definitions. Default Javadoc linting behavior in JDK8 considers it as an error

I will take care of it in future.

@Vlatombe
Copy link
Member

@rupinr this is instruction for the merger (GitHub provides directly the ability to squash before merge)

@rupinr
Copy link
Contributor Author

rupinr commented Jul 15, 2016

@Vlatombe So, I guess nothing is pending from my side. Right?

@oleg-nenashev oleg-nenashev merged commit 0b51770 into jenkinsci:master Jul 15, 2016
@oleg-nenashev
Copy link
Member

@rupinr Merged the PR. Thanks for your contribution!

@serafeimgr
Copy link

Thanks rupinr.
I am the reporter of this issue, should i close it?

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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in #2589, I think this is overkill. Better to just ignore the checkbox.

abayer added a commit to abayer/jenkins that referenced this pull request Jan 20, 2017
At least part of the impetus for this issue was dealt with a while
back by a revert of PR jenkinsci#2444, but this gives us a better solution
anyway by guaranteeing we have a null property rather than one without
parameters.
abayer added a commit to abayer/jenkins that referenced this pull request Jan 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-more-reviews Complex change, which would benefit from more eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants