-
Notifications
You must be signed in to change notification settings - Fork 742
Describable will give a warning on multiple implementations of a symbol #674
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
Describable will give a warning on multiple implementations of a symbol #674
Conversation
timja
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable, want to resolve the conflicts and try get a green build?
576249d to
30700cf
Compare
|
💪 I have too much power @timja |
|
CI is having a field day 😢 |
|
oh @dgarzon apparently it won't actually compile: https://ci.jenkins.io/blue/organizations/jenkins/Plugins%2Fconfiguration-as-code-plugin/detail/PR-674/23/pipeline#step-59-log-545 |
|
@Casz Thanks for pointing this out. I hope I can check this tomorrow in the office. |
|
@dgarzon this breaks binary compatibility, however, since none of the custom plugin configurators have been merged I think we are safe. It would require some rework in some of the PRs such as jenkinsci/job-dsl-plugin#1142 |
409352a to
1715987
Compare
1715987 to
52c0069
Compare
|
Moved my extra work to a separate PR, it started to become more work than I expected 😄 |
|
@Casz will take a look tomorrow, I feel responsible to get this fixed :) |
|
@dgarzon 👀 🙈 |
| .collect(Collectors.toMap( | ||
| d -> DescribableAttribute.getSymbols(d, api, target).get(0), | ||
| d -> d.getKlass().toJavaClass())); | ||
| @SuppressWarnings("unused") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need this suppression given its used in tests?
if you do need one maybe VisibleForTesting would be better
| return Option.of(Jenkins.getInstance().getPlugin(name)).isDefined(); | ||
| } | ||
|
|
||
| private HashMap<String, Descriptor<T>> handleDuplicateSymbols(HashMap<String, Descriptor<T>> r, Tuple2<String, Descriptor<T>> t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not very clear what the parameters are here, what are r and t?
also do we need to be using HashMap or can we use Map?
| @Nonnull | ||
| @Override | ||
| public List<Configurator> getConfigurators(ConfigurationContext context) { | ||
| public List<Configurator<GeneratedItems[]>> getConfigurators(ConfigurationContext context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks unrelated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is very much related. The Configurator class was changed to actually need the type defined and not done through reflection. Hence the binary incompatibility fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great, and nice test. Have asked a couple of question but no blockers
|
@dgarzon 🙏 |
ac2cbc0 to
805b651
Compare
805b651 to
021240b
Compare
021240b to
54e2b59
Compare
|
@Casz this ready to go? |
|
It is, I just want @dgarzon to have look at it again with my additions 😅 |
|
Thanks @Casz for taking care of this! Looks good on my end :) Been super busy at work, hopefully I will free up a bit and be back here to contribute more often! |
|
🙌 |
|
If the descriptor list of the describable attribute is empty, another problem raise up in the schema, because of the "oneOf" which expects at least one item. |
|
@BlueAndi wrap it in a |
|
Previous mentioned problem fixed in db44a1e Regarding the I don't get the point about the whole construction, as I think "schema" misses a dollar sign as well. |
This PR addresses #658 and #657 on the CasC side of things. Currently, if there are duplicate symbols both the
configureandgetImplementorsmethods throw ugly exceptions. Ideally, they should not throw and instead log a warning to the user to report the duplicates to maintainers.I may have gone a bit overboard with the refactoring, but I think it is valuable nonetheless. The code now is easier to reason about as I have moved code to functions and given them clear names. Also tried to DRY this as much as possible.
Behavior:
getImplementors: if a duplicate key is found, we discard it, and logFound multiple implementations for symbol = fooBar: [foo.bar.FooBar, foo.baz.FooBar]. Please report to plugin maintainer.configure: if a duplicate key is found, we logFound multiple implementations for symbol = fooBar: [foo.bar.FooBar, foo.baz.FooBar]. Please report to plugin maintainer.and configure the first instance returned bygetDescriptors()which is the same behavior we had before this refactoring.