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-43934] Flatten GString’s found in step arguments, even when present in nested collections #123

Merged
merged 1 commit into from May 9, 2017

Conversation

jglick
Copy link
Member

@jglick jglick commented May 9, 2017

JENKINS-43934

Never really posed a problem before, probably because there is no existing StepDescriptor.newInstance override which would be expecting evaluated Strings in a collection type, but the previous behavior was at least potentially wrong…and this is needed for #98 so we might as well do it anyway.

DescribableModel already has GString handling, which really should never have been there, but we cannot remove that compatibly.

@reviewbybees

@jglick jglick requested review from abayer and svanoort May 9, 2017 19:11
if (b.length() > 0) {
b.append(' ');
}
b.append((String) arg);
Copy link
Member Author

Choose a reason for hiding this comment

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

Admittedly artificial, but at any rate this throws a ClassCastException without the fix.

@ghost
Copy link

ghost commented May 9, 2017

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.

Copy link
Member

@abayer abayer left a comment

Choose a reason for hiding this comment

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

Nice!

List<Object> r = new ArrayList<>();
for (Object o : ((List<?>) v)) {
Object o2 = flattenGString(o);
mutated |= o != o2;
Copy link
Member

Choose a reason for hiding this comment

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

Creative use of syntax.

r.put(k2, o2);
}
return mutated ? r : v;
} else {
Copy link
Member

Choose a reason for hiding this comment

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

@jglick What about Sets, general collections?

Probably omitting those types is a bug, but this is still better than before, so I'm happy seeing it merged that way because it is still a million times better.

Copy link
Member Author

Choose a reason for hiding this comment

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

I deliberately considered only Lists and Maps because these are the types that DescribableModel processes and that are generally used in Describable configuration and thus Step syntax. (Actually the interpreted Maps are more specific than that—only String-keyed maps, and only for the purpose of representing nested Describables à la $class—but easiest to just process Maps generically, and should be harmless.)

Copy link
Member

Choose a reason for hiding this comment

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

That's reasonable enough, thanks for explaining.

Not sure if there's an explicit restriction on Set/Collection types here, but that's good enough for me.

@jglick
Copy link
Member Author

jglick commented May 9, 2017

Argh, npm strikes again! I need to set aside some time to try to use jenkinsci/plugin-pom#57

@jglick jglick closed this May 9, 2017
@jglick jglick reopened this May 9, 2017
@jglick jglick closed this May 9, 2017
@jglick jglick reopened this May 9, 2017
@jglick
Copy link
Member Author

jglick commented May 9, 2017

@reviewbybees done

Now trying to rerun tests on my laptop since the npm download is busted, sigh; see INFRA-1139.

@jglick jglick merged commit ef0d963 into jenkinsci:master May 9, 2017
@jglick jglick deleted the flattenGString branch May 9, 2017 21:47
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