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

Improve checkApiUrlValidity() method #251

Merged
merged 1 commit into from Mar 12, 2016

Conversation

recena
Copy link
Contributor

@recena recena commented Mar 5, 2016

Part of JENKINS-33318

@reviewbybees, specially @kohsuke and @cyrille-leclerc

@ghost
Copy link

ghost commented Mar 5, 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.

try {
retrieve().to("/", GHApiInfo.class).check(apiUrl);
} catch (IOException ioe) {
if (isPrivateModeEnabled()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not convinced this check is enough. There may be other errors (e.g. network failure), but this check suppresses all other issues. Maybe you should throw a new exception with the cause and a message, which says that it maybe related to the private mode

Copy link
Contributor

Choose a reason for hiding this comment

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

Same feeling here, I would prefer a logic based on the HTTP error code (401 for private mode, http proxy auth...) and on the Network exception (connection refused, ssl handshake rejected for negotiation failure...). I am investigating to make proposals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The method basically is the same but now we have included a new case.

I tested with:

  1. https://api.github.com/
  2. http://github.mycompany.com/api/v3/
  3. https://github.mycompany.com/api/v3/ (self-signed certificate)
  4. https://github.mycompany.com/api/v3/ (certificate)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A Network exception throws a IOException and turns out an negative validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@oleg-nenashev

but this check suppresses all other issues

Why? How? I'm only handling a special case. If private mode is not configured and there is an problem, an exception is thrown.

Maybe you should throw a new exception with the cause and a message, which says that it maybe related to the private mode

The exception is thrown with a customized message (IMO, very clear). The doubt can be about the way used to verify the privade mode.

@recena recena closed this Mar 6, 2016
@recena recena reopened this Mar 7, 2016
@kohsuke kohsuke merged commit ae85cf4 into hub4j:master Mar 12, 2016
kohsuke added a commit that referenced this pull request Mar 12, 2016
Conflicts:
	src/main/java/org/kohsuke/github/GitHub.java
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.

None yet

4 participants