- All Implemented Interfaces:
-
Serializable
Merely creating or throwing this exception is not sufficient to indicate blocking. Current reactive computation must be explicitly marked as blocked before throwing by calling CurrentReactiveScope.block(). This class defines convenience block() method and its overloads that call CurrentReactiveScope.block() before throwing ReactiveBlockingException.
Reactive code should preferably return fallback in case it signals blocking, because that allows the rest of the code to continue and to trigger further blocking operations. This way all blocking operations (e.g. database queries) can execute in parallel.
It is however sometimes impossible to provide a reasonable fallback result. In those cases, throwing an exception is acceptable.
This exception type is provided as the most descriptive for cases of reactive blocking. Its use is not mandatory though. Code that reactively blocks may throw any exception.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs newReactiveBlockingException.ReactiveBlockingException(String message) Constructs newReactiveBlockingExceptionwith the specified message.ReactiveBlockingException(String message, Throwable cause) Constructs newReactiveBlockingExceptionwith the specified message and cause.Constructs newReactiveBlockingExceptionwith the specified cause. -
Method Summary
Modifier and TypeMethodDescriptionstatic ReactiveBlockingExceptionblock()static ReactiveBlockingExceptionMarks the currentReactiveScopeas blocking and then throwsReactiveBlockingExceptionwith the specified message.static ReactiveBlockingExceptionMarks the currentReactiveScopeas blocking and then throwsReactiveBlockingExceptionwith the specified message and cause.static ReactiveBlockingExceptionMarks the currentReactiveScopeas blocking and then throwsReactiveBlockingExceptionwith the specified cause.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ReactiveBlockingException
Constructs newReactiveBlockingExceptionwith the specified message and cause.Merely calling this constructor does not block current
ReactiveScope. Useblock(String, Throwable)for that.- Parameters:
-
message- informative message (possiblynull) that can be later retrieved viaThrowable.getMessage() -
cause- cause of this exception (possiblynull) that can be later retrieved viaThrowable.getCause() - See Also:
-
ReactiveBlockingException
Constructs newReactiveBlockingExceptionwith the specified message.Merely calling this constructor does not block current
ReactiveScope. Useblock(String)for that.- Parameters:
-
message- informative message (possiblynull) that can be later retrieved viaThrowable.getMessage() - See Also:
-
ReactiveBlockingException
Constructs newReactiveBlockingExceptionwith the specified cause. Ifcauseis notnull, message string of this exception will be set tocause.toString().Merely calling this constructor does not block current
ReactiveScope. Useblock(Throwable)for that.- Parameters:
-
cause- cause of this exception (possiblynull) that can be later retrieved viaThrowable.getCause() - See Also:
-
ReactiveBlockingException
public ReactiveBlockingException()Constructs newReactiveBlockingException. The exception will have no message, i.e. it will returnnullfromThrowable.getMessage().Merely calling this constructor does not block current
ReactiveScope. Useblock()for that.- See Also:
-
-
Method Details
-
block
Marks the currentReactiveScopeas blocking and then throwsReactiveBlockingExceptionwith the specified message and cause. Current reactive scope is blocked by callingCurrentReactiveScope.block().This method always throws and thus never returns. Declared return type is just a convenience that lets callers avoid unreachable code errors by placing the call in a
throwstatement, e.g.throw ReactiveBlockingException.block(...).- Parameters:
-
message- message (possiblynull) passed toReactiveBlockingException(String, Throwable) -
cause- cause (possiblynull) passed toReactiveBlockingException(String, Throwable) - Returns:
- never returns
- See Also:
-
block
Marks the currentReactiveScopeas blocking and then throwsReactiveBlockingExceptionwith the specified message. Current reactive scope is blocked by callingCurrentReactiveScope.block().This method always throws and thus never returns. Declared return type is just a convenience that lets callers avoid unreachable code errors by placing the call in a
throwstatement, e.g.throw ReactiveBlockingException.block(...).- Parameters:
-
message- message (possiblynull) passed toReactiveBlockingException(String) - Returns:
- never returns
- See Also:
-
block
Marks the currentReactiveScopeas blocking and then throwsReactiveBlockingExceptionwith the specified cause. Current reactive scope is blocked by callingCurrentReactiveScope.block().This method always throws and thus never returns. Declared return type is just a convenience that lets callers avoid unreachable code errors by placing the call in a
throwstatement, e.g.throw ReactiveBlockingException.block(...).- Parameters:
-
cause- cause (possiblynull) passed toReactiveBlockingException(Throwable) - Returns:
- never returns
- See Also:
-
block
Marks the currentReactiveScopeas blocking and then throwsReactiveBlockingException. Current reactive scope is blocked by callingCurrentReactiveScope.block().This method always throws and thus never returns. Declared return type is just a convenience that lets callers avoid unreachable code errors by placing the call in a
throwstatement, e.g.throw ReactiveBlockingException.block(...).- Returns:
- never returns
- See Also:
-