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

Fix for #523 #570

Merged
merged 2 commits into from
Nov 20, 2017
Merged

Fix for #523 #570

merged 2 commits into from
Nov 20, 2017

Conversation

sverkera
Copy link

@sverkera sverkera commented Sep 13, 2017

This issue is caused by the github lib on these occasions will catch an IOException and wrap it in a java.lang.Error. This plugin has a catch-all in the thread for Exceptions, but that does not catch an Error.

I've changed that to catch Throwable, which will catch both Error and Exception. I've also added some catching of Error higher up where it catches IOException.

Edit by @samrocketman: Fix for #523

… will catch also java.lang.Error

Catch also Error on some locations where IOException is catched, as the github lib sometimes will catch IOException and wrap it in an Error
@anauckunas
Copy link

Can someone please merge this

@bjoernhaeuser
Copy link
Contributor

can you link the code which wraps the exception in an error? That alreadys sound off and should be changed - IMHO.

@bjoernhaeuser bjoernhaeuser changed the title Fix for https://github.com/jenkinsci/ghprb-plugin/issues/523 Fix for #523 Nov 19, 2017
@@ -250,13 +250,13 @@ private void triggerPr(final GhprbTrigger trigger,
public void run() {
try {
trigger.handlePR(pr);
} catch (Exception e) {
} catch (Throwable th) {
Copy link
Member

Choose a reason for hiding this comment

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

In general, I've been told catching Throwable is a bad idea. Can a more seasoned Jenkins dev review this PR?

cc @jenkinsci/code-reviewers

Copy link
Member

Choose a reason for hiding this comment

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

If the intention here is to catch Exception and Error, then check for those types and if it's not either of those types then rethrow throwable. I'm just concerned that we're swallowing all throwable.

Copy link
Member

@samrocketman samrocketman Nov 20, 2017

Choose a reason for hiding this comment

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

Also, a quote from the java.lang.Error javadoc:

An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch.

I need an adult 🆘

Copy link
Member

Choose a reason for hiding this comment

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

It's a bad style for sure. But, you know, throwing it from the code is a bad idea as well :(

Copy link
Member

Choose a reason for hiding this comment

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

In practice the main things it is problematic to catch are OutOfMemoryError (generally no practical recovery, so does not make much difference either way); and ThreadDeath (you need to be sure to rethrow quickly at least).

Copy link
Member

Choose a reason for hiding this comment

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

I'll open up a followup PR @jglick. I guess I merged too quickly.

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

👍 since you do not have much choice here, but generally the mess with Errors in GitHub API should be cleaned up (https://github.com/kohsuke/github-api/search?utf8=%E2%9C%93&q=%22new+Error%22&type=). At least it makes sense to replace them by common runtime exceptions like IllegalStateException or whatever

@@ -250,13 +250,13 @@ private void triggerPr(final GhprbTrigger trigger,
public void run() {
try {
trigger.handlePR(pr);
} catch (Exception e) {
} catch (Throwable th) {
Copy link
Member

Choose a reason for hiding this comment

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

It's a bad style for sure. But, you know, throwing it from the code is a bad idea as well :(

@samrocketman
Copy link
Member

@bjoernhaeuser I'm headed to bed now. I trust @oleg-nenashev judgement on this one. When the PR finishes verifying do you mind merging? I'll get to it tomorrow if it's not merged so not a big deal if you don't have time.

@samrocketman samrocketman merged commit 19d5540 into jenkinsci:master Nov 20, 2017
nosmo pushed a commit to nosmo/ghprb-plugin that referenced this pull request Dec 12, 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.

7 participants