Skip to content

Apply consistent Exception variable names to all catch blocks #2749

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 2 commits into from

Conversation

jxblum
Copy link
Contributor

@jxblum jxblum commented Oct 19, 2023

See #2748.

It should also be NOTED that, in certain catch (InterruptedException ex) blocks, the ex Exception variable was not used or referenced. However, that does NOT mean the Exception handler did not "handle" the InterruptedException!

The simple invocation of Thread.currentThread().interrupt() IS an act of handling the InterruptedException and does have downstream consequences (or in other words, "side effects"). Therefore, the Exception variable name ex was deliberately kept in these cases.

@jxblum jxblum added the type: task A general task label Oct 19, 2023
@jxblum jxblum added this to the 3.2 GA (2023.1.0) milestone Oct 19, 2023
@jxblum jxblum changed the title Apply consistent Exception variable names to all catch blocks Apply consistent Exception variable names to all catch blocks Oct 19, 2023
We now consistently align with the core Spring Framework's use of 'ex' as the variable name for Exceptions handled in catch blocks, and 'ignore' for all Exceptions thrown, but ignored by framework code. Both 'ex' and 'ignore' were appropriately used based on the context and nautre of the Exception handler in the catch block.

Additionally, we use the 'expected' variable name for Exception thrown in tests where the thrown Exception is the expected outcome of the test case.

Only 1 exception exists to these name conventions, and that is 'nested', which was necessarily used in ScanCursor due to the nested try-catch blocks.

Applied consistent use of String.format(..) to Exception messages requiring formatting.

Formatted catch block according to source code formatting style.

Closes #2748
@jxblum jxblum changed the title Apply consistent Exception variable names to all catch blocks Apply consistent Exception variable names to all catch blocks Oct 19, 2023
@@ -123,8 +123,8 @@ public JedisClusterConnection(JedisCluster cluster) {
Object custerCommandExecutor = executorDfa.getPropertyValue("executor");
DirectFieldAccessor dfa = new DirectFieldAccessor(custerCommandExecutor);
clusterCommandExecutor.setMaxRedirects((Integer) dfa.getPropertyValue("maxRedirects"));
} catch (Exception e) {
// ignore it and work with the executor default
} catch (Exception ignore) {
Copy link
Member

Choose a reason for hiding this comment

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

🥳

@mp911de
Copy link
Member

mp911de commented Oct 19, 2023

Looks pretty decent, thank you. It makes sense to backport the changes into 3.1.x as well so we simplify future backports.

@mp911de mp911de self-assigned this Oct 19, 2023
mp911de pushed a commit that referenced this pull request Oct 19, 2023
We now consistently align with the core Spring Framework's use of 'ex' as the variable name for Exceptions handled in catch blocks, and 'ignore' for all Exceptions thrown, but ignored by framework code. Both 'ex' and 'ignore' were appropriately used based on the context and nautre of the Exception handler in the catch block.

Additionally, we use the 'expected' variable name for Exception thrown in tests where the thrown Exception is the expected outcome of the test case.

Only 1 exception exists to these name conventions, and that is 'nested', which was necessarily used in ScanCursor due to the nested try-catch blocks.

Applied consistent use of String.format(..) to Exception messages requiring formatting.

Formatted catch block according to source code formatting style.

Closes #2748
Original pull request: #2749
mp911de pushed a commit that referenced this pull request Oct 19, 2023
We now consistently align with the core Spring Framework's use of 'ex' as the variable name for Exceptions handled in catch blocks, and 'ignore' for all Exceptions thrown, but ignored by framework code. Both 'ex' and 'ignore' were appropriately used based on the context and nautre of the Exception handler in the catch block.

Additionally, we use the 'expected' variable name for Exception thrown in tests where the thrown Exception is the expected outcome of the test case.

Only 1 exception exists to these name conventions, and that is 'nested', which was necessarily used in ScanCursor due to the nested try-catch blocks.

Applied consistent use of String.format(..) to Exception messages requiring formatting.

Formatted catch block according to source code formatting style.

Closes #2748
Original pull request: #2749
@mp911de
Copy link
Member

mp911de commented Oct 19, 2023

Thank you for your contribution. That's merged and backported now.

@mp911de mp911de closed this Oct 19, 2023
@mp911de mp911de deleted the issue/2748 branch October 19, 2023 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refine all catch blocks to use consistent naming for Exception variables
2 participants