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

[JENKINS-34070] Better handle mismatched types #4

Merged
merged 2 commits into from Apr 8, 2016

Conversation

jglick
Copy link
Member

@jglick jglick commented Apr 7, 2016

JENKINS-34070

Prior to fix, the test would fail with a misleading error:

org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class org.jenkinsci.plugins.gitclient.MergeCommand$Strategy
    at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:177)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.<init>(DescribableModel.java:114)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.of(DescribableModel.java:100)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate__(DescribableModel.java:477)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate_(DescribableModel.java:474)
    at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:174)
    at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:122)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate(DescribableModel.java:435)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate__(DescribableModel.java:477)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate_(DescribableModel.java:474)
    at org.jenkinsci.plugins.structs.describable.DescribableModelTest.roundTrip(DescribableModelTest.java:636)
    at org.jenkinsci.plugins.structs.describable.DescribableModelTest.userMergeOptions(DescribableModelTest.java:600)

Now it will still fail, but only with incorrect output:

expected:<{fastForwardMode=FF_ONLY, mergeRemote=x, mergeStrategy=OCTOPUS, mergeTarget=y}> but was:<{fastForwardMode=FF_ONLY, mergeRemote=x, mergeStrategy=default, mergeTarget=y}>

after printing a warning that more accurately represents what is wrong in the signature of UserMergeOptions:

WARNING: Cannot create control version of class hudson.plugins.git.UserMergeOptions using {fastForwardMode=FF_ONLY, mergeRemote=x, mergeStrategy=default, mergeTarget=y}
java.lang.ClassCastException: hudson.plugins.git.UserMergeOptions.mergeStrategy expects class java.lang.String but received class org.jenkinsci.plugins.gitclient.MergeCommand$Strategy
    at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:326)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:257)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:201)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate(DescribableModel.java:449)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate__(DescribableModel.java:477)
    at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate_(DescribableModel.java:474)
    at org.jenkinsci.plugins.structs.describable.DescribableModelTest.roundTrip(DescribableModelTest.java:636)
    at org.jenkinsci.plugins.structs.describable.DescribableModelTest.userMergeOptions(DescribableModelTest.java:600)

@reviewbybees

@ghost
Copy link

ghost commented Apr 7, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@jenkinsadmin
Copy link
Member

Thank you for this pull request! Please check this document for how the Jenkins project handles pull requests.

@andresrc
Copy link

andresrc commented Apr 8, 2016

🐝

@jglick jglick merged commit f22060e into jenkinsci:master Apr 8, 2016
@jglick jglick deleted the JENKINS-34070-mismatch branch April 8, 2016 14:32
jglick added a commit to jglick/structs-plugin that referenced this pull request Apr 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants