-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix AsyncTimeout in presence of retries
Previously, `AsyncTimeout` used the `InvocationContext` event system to communicate with the `Timeout` strategy. This had 2 flaws in presence of retries: - the set of event handlers grew up with each retry, resulting in unnecessary attempts to complete a `Future` that has already been completed (silly, but harmless); - a delayed (due to thread scheduling) timeout event from one retry iteration could trigger immediate timeout for subsequent retry iteration (big problem!). With this commit, `AsyncTimeout` and `Timeout` use the `InvocationContext` contextual data system and don't suffer from these issues. This is because the `Timeout` class picks up the contextual data item that's used for communicating with `AsyncTimeout` synchronously, so that it's always the one belonging to the "current" retry iteration, and even deletes it immediately after picking it up.
- Loading branch information
Showing
6 changed files
with
53 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
.../core/src/main/java/io/smallrye/faulttolerance/core/timeout/AsyncTimeoutNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.smallrye.faulttolerance.core.timeout; | ||
|
||
import org.eclipse.microprofile.faulttolerance.exceptions.TimeoutException; | ||
|
||
@FunctionalInterface | ||
interface AsyncTimeoutNotification { | ||
void accept(TimeoutException timeoutException); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
implementation/core/src/main/java/io/smallrye/faulttolerance/core/timeout/TimeoutLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
package io.smallrye.faulttolerance.core.timeout; | ||
|
||
import static org.jboss.logging.annotations.Message.NONE; | ||
|
||
import org.eclipse.microprofile.faulttolerance.exceptions.TimeoutException; | ||
import org.jboss.logging.BasicLogger; | ||
import org.jboss.logging.Logger; | ||
import org.jboss.logging.annotations.LogMessage; | ||
import org.jboss.logging.annotations.Message; | ||
import org.jboss.logging.annotations.MessageLogger; | ||
import org.jboss.logging.annotations.Transform; | ||
|
||
@MessageLogger(projectCode = "SRFTL", length = 5) | ||
interface TimeoutLogger extends BasicLogger { | ||
TimeoutLogger LOG = Logger.getMessageLogger(TimeoutLogger.class, TimeoutLogger.class.getPackage().getName()); | ||
|
||
@Message(id = NONE, value = "AsyncTimeoutTask %s created") | ||
@LogMessage(level = Logger.Level.TRACE) | ||
void asyncTimeoutTaskCreated(@Transform(Transform.TransformType.IDENTITY_HASH_CODE) Object task); | ||
|
||
@Message(id = NONE, value = "AsyncTimeoutTask %s completing with %s") | ||
@LogMessage(level = Logger.Level.TRACE) | ||
void asyncTimeoutTaskCompleting(@Transform(Transform.TransformType.IDENTITY_HASH_CODE) Object task, TimeoutException e); | ||
|
||
@Message(id = NONE, value = "AsyncTimeout rethrowing %s") | ||
@LogMessage(level = Logger.Level.TRACE) | ||
void asyncTimeoutRethrowing(Throwable e); | ||
} |