Package io.bytestreams.exchange.core
Interface ErrorHandler<REQ,RESP>
- Type Parameters:
REQ- the request message typeRESP- the response message type
public interface ErrorHandler<REQ,RESP>
Handles channel errors.
The default implementation returns true, which stops the channel (closes the
transport) on the first error. Override and return false for specific errors you wish to
tolerate — for example, transient I/O errors on a connection you want to keep alive.
Note: This handler covers errors in the read and write loops, including exceptions
thrown by a RequestHandler. Only Error subclasses (e.g. OutOfMemoryError) bypass this handler and are caught by the channel's outer safety net, which
closes the transport unconditionally.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanstopOnError(Channel channel, ErrorContext<REQ, RESP> context) Called when an error occurs on the channel.
-
Method Details
-
stopOnError
Called when an error occurs on the channel. Returntrueto stop the channel (close transport);falseto continue processing.- Parameters:
channel- the channel on which the error occurredcontext- the error context- Returns:
trueto stop,falseto continue
-