Skip to content

Use an unchecked exception for unsupported MAC algorithms#29

Merged
jchambers merged 1 commit into
masterfrom
no_such_algorithm_runtime_exception
Jan 9, 2022
Merged

Use an unchecked exception for unsupported MAC algorithms#29
jchambers merged 1 commit into
masterfrom
no_such_algorithm_runtime_exception

Conversation

@jchambers

Copy link
Copy Markdown
Owner

This introduces a NoSuchAlgorithmRuntimeException to take the place of NoSuchAlgorithmException. The rationale is that, in virtually all cases, a NoSuchAlgorithmException is practically impossible because all JVMs are required to support SHA-1 and SHA-256. The one exception is SHA-512, which JVMs are not required to support (but most do).

Re-throwing NoSuchAlgorithmException as a NoSuchAlgorithmRuntimeException means that callers don't need to catch an exception that can never happen in most cases; in the one case where it can happen, we'll rely on the docs to warn callers that they should be on the lookout for a NoSuchAlgorithmRuntimeException.

My hope is that this is a worthwhile tradeoff in favor of API ergonomics, but I welcome feedback!

@jchambers jchambers force-pushed the no_such_algorithm_runtime_exception branch from 755a1a8 to 3b4dc0d Compare November 20, 2021 17:50
@jchambers jchambers added this to the 0.4.0 milestone Nov 20, 2021
@jchambers jchambers force-pushed the no_such_algorithm_runtime_exception branch from 3b4dc0d to f1e62ba Compare December 27, 2021 16:45
@jchambers jchambers merged commit f9e0fcb into master Jan 9, 2022
@jchambers jchambers deleted the no_such_algorithm_runtime_exception branch January 9, 2022 02:12
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.

1 participant