Interface ForeignExceptionSnare

All Known Implementing Classes:
DisabledTableSnapshotHandler, EnabledTableSnapshotHandler, ForeignExceptionDispatcher, TakeSnapshotHandler

@Private public interface ForeignExceptionSnare
This is an interface for a cooperative exception throwing mechanism. Implementations are containers that holds an exception from a separate thread. This can be used to receive exceptions from 'foreign' threads or from separate 'foreign' processes.

To use, one would pass an implementation of this object to a long running method and periodically check by calling rethrowException(). If any foreign exceptions have been received, the calling thread is then responsible for handling the rethrown exception.

One could use the boolean hasException() to determine if there is an exceptoin as well.

NOTE: This is very similar to the InterruptedException/interrupt/interrupted pattern. There, the notification state is bound to a Thread. Using this, applications receive Exceptions in the snare. The snare is referenced and checked by multiple threads which enables exception notification in all the involved threads/processes.

  • Method Details

    • rethrowException

      Rethrow an exception currently held by the ForeignExceptionSnare. If there is no exception this is a no-op all exceptions from remote sources are procedure exceptions
      Throws:
      ForeignException
    • hasException

      boolean hasException()
      Non-exceptional form of rethrowException(). Checks to see if any process to which the exception checkers is bound has created an error that would cause a failure.
      Returns:
      true if there has been an error,false otherwise
    • getException

      Get the value of the captured exception.
      Returns:
      the captured foreign exception or null if no exception captured.