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

Document the reason RetryerException#getLastFailedAttempt returns Attempt<?> #222

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/org/kiwiproject/retry/RetryException.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public int getNumberOfFailedAttempts() {
* Returns the last failed attempt
*
* @return the last failed attempt
* @apiNote This method returns {@code Attempt<?>} because the Java Language Specification does not
* permit generic subclasses of Throwable. In section
* <a href="https://docs.oracle.com/javase/specs/jls/se17/html/jls-8.html#jls-8.1.2">8.1.2, Generic Classes and Type Parameters</a>,
* the (Java SE 17) specification states that <em>"It is a compile-time error if a generic class is a direct or
* indirect subclassof Throwable"</em>. It further provides the reason, stating <em>"This restriction is needed
* since the catch mechanism of the Java Virtual Machine works only with non-generic classes."</em> As a result,
* this exception class has no (good) way to capture the {@code Attempt} type parameter. Callers of this
* method must know the expected type and cast the returned value.
*/
public Attempt<?> getLastFailedAttempt() {
return lastFailedAttempt;
Expand Down