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

onLoad(FlowExecutionOwner) is meant to throw IOException #201

Merged
merged 1 commit into from
Feb 16, 2022

Conversation

jglick
Copy link
Member

@jglick jglick commented Feb 16, 2022

Reverting an incorrect change (I suppose caused by unvalidated use of some refactoring tool by @offa) from #185.

@jglick jglick added the bug label Feb 16, 2022
@jglick jglick requested review from dwnusbaum and car-roll February 16, 2022 17:55
@dwnusbaum
Copy link
Member

I think FlowExecutionOwner.getListener also needs to have throws IOException added back for WorkflowRun.Owner.getListener.

@jglick jglick mentioned this pull request Feb 16, 2022
6 tasks
@jglick
Copy link
Member Author

jglick commented Feb 16, 2022

I think FlowExecutionOwner.getListener also needs to have throws IOException added back

public @NonNull TaskListener getListener() throws IOException {
is still OK. is just a private impl, should not be a problem.

@jglick
Copy link
Member Author

jglick commented Feb 16, 2022

@offa please disable whichever IDE suggestion you may have to automatically strip unthrown exceptions as this is not safe to use without human inspection in general.

@jglick jglick enabled auto-merge February 16, 2022 18:02
@jglick jglick merged commit 619fd52 into jenkinsci:master Feb 16, 2022
@basil
Copy link
Member

basil commented Feb 16, 2022

@offa please disable whichever IDE suggestion you may have to automatically strip unthrown exceptions as this is not safe to use without human inspection in general.

Yeah, I tend to ignore this IDE suggestion in general. The one case where I have found it useful is for removing e.g. throws Exception from test methods that don't need it, but even in that case the value of the suggestion seems dubious.

@jglick jglick deleted the IOException branch February 17, 2022 15:10
@offa
Copy link
Contributor

offa commented Feb 17, 2022

Sorry for introducing a regression with my PR; I've checked changes, ran tests etc. but didn't verify downstream consumers like cps.

In my personal opinion declared but not thrown exceptions should get removed as they lie to the caller, may reduce readability and force them to write additional code to handle situations that wont ever appear or are impossible. Without breaking anything of course – unlike here.

Again, my opinion and it's totally fine to disagree.

If there's a consensus or recommendation to leave not-thrown exceptions alone I'm fully ok with that.

Thanks @jglick for fixing it up.

@jglick
Copy link
Member Author

jglick commented Feb 17, 2022

Sorry for introducing a regression with my PR

No worries, everyone does sometimes! This only caused a source incompatibiilty (no effect on Jenkins users updating).

declared but not thrown exceptions should get removed

In some cases sure. But not if the method is intended to be overridden outside the module. Or if it is a test which will quite possibly sooner or later wind up throwing a checked exception. Or if the method is part of some public API and there is the notion to later change its body to something that might throw that exception. Or if there are some callers (in another module) which would no longer compile because they currently catch this exception, unless you have a plan to fix them up too. And so on. Basically it requires human review in each case, so is not safe to enable in batch as part of mechanical code cleanup PRs, and in most cases I have seen I would actually prefer the change be reverted even if it does not much matter either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants