Skip to content

Revise all the throws Exception; // NOSONAR #3421

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
artembilan opened this issue Nov 5, 2020 · 9 comments · Fixed by #3916
Closed

Revise all the throws Exception; // NOSONAR #3421

artembilan opened this issue Nov 5, 2020 · 9 comments · Fixed by #3916

Comments

@artembilan
Copy link
Member

For example we have a code in the WebSocketListener like this:

void onMessage(WebSocketSession session, WebSocketMessage<?> message)
			throws Exception; // NOSONAR Remove in 5.2

so, all those throws Exception have to be removed.

@artembilan artembilan added this to the 6.0.x milestone Nov 5, 2020
@artembilan artembilan added the ideal-for-user-contribution An issue that would ideal for a user to get started with contributing. label Mar 23, 2021
@artembilan artembilan modified the milestones: 6.0.x, Backlog Mar 23, 2021
@askzy
Copy link

askzy commented Apr 13, 2021

is this for every class in the entire codebase?
any guidelines on how to revise these throw exceptions?

@artembilan
Copy link
Member Author

I just did a search for this sentence: throws Exception; // NOSONAR:

image

So, not too much.

The goal is to not have such a generic throws Exception; at all.
The revision indeed depends on the impl of such a contract: sometimes it is going to work as is because the impl already does a good job for error handling or it just re-throw a RuntimeException which doesn't require throws Exception; contract.

In other places we would need to what exceptions are thrown and re-throw them as some particular RuntimeException: sometimes an IllegalStateException is enough; sometimes it has to be a MessagingException...

Let's see what is going on when you just remove them and build the project gradlew check !

@mipo256
Copy link

mipo256 commented Mar 24, 2022

@artembilan I think I can take care of that

@artembilan artembilan modified the milestones: Backlog, 6.0 M3 Mar 24, 2022
@artembilan
Copy link
Member Author

Sure!

Just pull the latest main, switch to Java 17 and go ahead with the fix!

Feel free to PR or leave comments over here if something is off or out of your control.

Thank you!

@artembilan artembilan modified the milestones: 6.0 M3, 6.0.x May 18, 2022
@aml8801
Copy link

aml8801 commented Jun 2, 2022

Hello guys
@Mikhail2048 are you still on this issue?
If not, I would like to do it.

best regards

@artembilan
Copy link
Member Author

Hi @aml8801 !

You know it doesn't matter for the project who contributes the fix and since there is no any news from @mikhail2048 for a couple months already, I think it is safe for you to take this issue and PR the fix.

Thank you!

@aml8801
Copy link

aml8801 commented Jun 6, 2022

Hello again,
Thanks for the fast reply. I applied for a few issues to work on and decided to start with another issue first. After I'm done with that one I'll be back here. If someone other want to do it earlier it ok either.
best regards

@artembilan
Copy link
Member Author

Hi there!

We are heading to RC1 soon enough.
It would be great if we incorporate the fix for this issue: it is going to be a breaking change in the API we expose.
It is OK if no one takes it but me: just need to know until the end of next week.

Thank you for understanding!

@artembilan artembilan self-assigned this Oct 14, 2022
@artembilan artembilan modified the milestones: 6.0.x, 6.0.0-RC1 Oct 14, 2022
artembilan added a commit to artembilan/spring-integration that referenced this issue Oct 14, 2022
Fixes spring-projects#3421

Remove `throws Exception;` from production code to honor
the rule `Generic exceptions should never be thrown` which is enabled on SonarQube

* Rework affected usages to `try..catch` with throwing respective runtime exception
or just logging
* Some other refactoring for the affected classes
@artembilan artembilan added type: refactoring and removed ideal-for-user-contribution An issue that would ideal for a user to get started with contributing. labels Oct 14, 2022
@artembilan
Copy link
Member Author

As I said before: we have release next week, so this breaking change must make it into the code base before 6.0 GA.
Therefore here you are PR: #3916

garyrussell pushed a commit that referenced this issue Oct 17, 2022
Fixes #3421

Remove `throws Exception;` from production code to honor
the rule `Generic exceptions should never be thrown` which is enabled on SonarQube

* Rework affected usages to `try..catch` with throwing respective runtime exception
or just logging
* Some other refactoring for the affected classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants