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

#164 - Annotate API methods in the Configurator extension point #165

Conversation

oleg-nenashev
Copy link
Member

@oleg-nenashev oleg-nenashev commented Apr 4, 2018

See #164. Just a first refactorings drop, which should improve issue diagnosability a bit

  • - Annotate API methods in the Configurator extension point
  • - Introduce ElementConverter interface which is a top-level interface for all converters
  • - Introduce ConverterException, switch convert() APIs to it
  • - Add some utility methods for null checks
  • - Fix error propagation and FindBugs issues

@reviewbybees

@oleg-nenashev
Copy link
Member Author

@ndeloof Probably we should put it on hold to discuss your feedback in #164 before merging

@ndeloof
Copy link
Contributor

ndeloof commented Apr 5, 2018

@oleg-nenashev no 👎 from me on this specific topic, so I'm fine with merging

@lanwen
Copy link
Member

lanwen commented Apr 5, 2018

I'm in the middle of the relocation process, so would be able to pay attention only week or so after, so please don't wait for me if it matters


private final static Logger logger = Logger.getLogger(Configurator.class.getName());


@CheckForNull
public static RootElementConfigurator lookupRootElement(String name) {
Copy link
Member

Choose a reason for hiding this comment

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

Probably should be Optional<...> as a return type, so we could use orElse to throw exceptions instead of verbosive if configurator == null

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe, let's wait for what the maintainers say

* @throws ConfiguratorException Configurator is not found
*/
@Nonnull
public static Configurator lookupOrFail(Type type) throws ConfiguratorException {
Copy link
Member

Choose a reason for hiding this comment

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

no need in such method if we get Optional one

@CheckForNull
private final ElementConfigurator configurator;

public ConfiguratorException(@CheckForNull ElementConfigurator configurator, @CheckForNull String message, @CheckForNull Throwable cause) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to see builder instead of all combinations of fields with two default constructors (String, Thr), (String).
I think you should always write a comment if you wrap another exception

@oleg-nenashev
Copy link
Member Author

@ewelinawilkosz @MadsNielsen any comments here?

@ewelinawilkosz
Copy link
Contributor

no comments from my site, great work!

@MadsNielsen
Copy link
Member

MadsNielsen commented Apr 18, 2018

@oleg-nenashev Looks fine to me

@lanwen Create a pull request once this has been merged with the proposed changes. I like most of the suggestion. Except i think the builder pattern might not be strictly necessary, when you only have one 3 arg constructor, that is manageble to work with in a proper editor.

But 👍 from here.

@lanwen
Copy link
Member

lanwen commented Apr 18, 2018

Interesting... :) Who does the review should fix the found notes?

@MadsNielsen
Copy link
Member

@lanwen I can do it :) ~ I'd just keep the optimization seperate, easier to review a smaller change like that.

@oleg-nenashev
Copy link
Member Author

@lanwen @MadsNielsen I am happy to switch APIs to optional if it helps, but I would also do it in a follow-up request. If anyone wants to do it, it should be a refactoring widely applied to all API. Otherwise Optional/Nullable inconsistency may be a PITA fo API users.

@MadsNielsen
Copy link
Member

@oleg-nenashev Then i'm ok with the merge. @ewelinawilkosz you ok as well?

@lanwen I'd be happy for you to review a pull request were we switch to this modern API, you seem to very familiar with it so it would make sense for you to review such a change seperately.

@ewelinawilkosz
Copy link
Contributor

yes! ok as well, just wanted to get a green light again from Oleg, since I got lost in the discussion :)
seems we have a way forward now and I'll merge that one

@ewelinawilkosz ewelinawilkosz merged commit bc7b54e into jenkinsci:master Apr 18, 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
Development

Successfully merging this pull request may close these issues.

5 participants