Skip to content

Pull #2291: Modernize codebase with Java improvements - Unnecessary throws #2291

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

Closed
wants to merge 1 commit into from

Conversation

Pankraz76
Copy link
Contributor

@Pankraz76 Pankraz76 commented May 2, 2025

@Pankraz76 Pankraz76 marked this pull request as ready for review May 2, 2025 19:20
@Pankraz76 Pankraz76 changed the title Pull #2287: Modernize codebase with Java improvements - Unnecessary throws Pull #2291: Modernize codebase with Java improvements - Unnecessary throws May 2, 2025
Pankraz76 pushed a commit to Pankraz76/maven that referenced this pull request May 2, 2025
@Pankraz76 Pankraz76 force-pushed the UnnecessaryThrows branch from bf48163 to 01e5e53 Compare May 2, 2025 20:17
Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

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

This may lead to incompatibilities if someone overrides a protected method and actually throw one exception that you removed. No incompatible change in compat modules is required.

@Pankraz76
Copy link
Contributor Author

This may lead to incompatibilities if someone overrides a protected method and actually throw one exception that you removed

new contract is not to throw; with checked it wont compile and runtime is always possible.

No incompatible change in compat modules is required.

so undo in this module and then any good ?

@Pankraz76 Pankraz76 force-pushed the UnnecessaryThrows branch from 01e5e53 to a84fac9 Compare May 4, 2025 08:22
@Pankraz76
Copy link
Contributor Author

No incompatible change in compat modules is required.

done.

@Pankraz76 Pankraz76 requested a review from gnodet May 4, 2025 08:23
Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

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

If you remove a throws clause from a protected method, any class that overrides this method won't be able to throw that exception, so that's an API change.

@Pankraz76 Pankraz76 changed the title Pull #2291: Modernize codebase with Java improvements - Unnecessary throws Pull #2291: Modernize codebase with Java improvements - Unnecessary throws May 8, 2025
@Pankraz76 Pankraz76 marked this pull request as draft May 9, 2025 11:22
@Pankraz76
Copy link
Contributor Author

Pankraz76 commented May 9, 2025

how to fix this permanent @timtebeek ? We dont have checkstyle for this.

Do we have the (local) dry run causing build failure check available?

I do not want to overload and spam PR´s like its done in rewrite. Ideally this breaks and fixes locally on dev´s machine/cost.

Thank you so much for this tool. Its a great needed help. We enlight the code so much.

This codebase is very smart as the code will format itself just like aimed in

but, its still not capable of fixing all like imports. This we will cover with help of rewrite again.

@timtebeek
Copy link
Contributor

Thanks all! Indeed we should not be making changes to an API that was explicitly marked as protected with exceptions declared;

timtebeek added a commit to openrewrite/rewrite-static-analysis that referenced this pull request May 10, 2025
* UnnecessaryThrows should not change API for protected methods

For apache/maven#2291
Needs openrewrite/rewrite#5412

* Adjust logic following review
@Pankraz76
Copy link
Contributor Author

wip reopen: wait for bugfix release or rewrite.

@Pankraz76 Pankraz76 closed this May 13, 2025
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.

4 participants