Class ExceptionProxy
- java.lang.Object
-
- org.apache.flink.streaming.connectors.kafka.internals.ExceptionProxy
-
@Internal @Deprecated public class ExceptionProxy extends Object
Deprecated.A proxy that communicates exceptions between threads. Typically used if an exception from a spawned thread needs to be recognized by the "parent" (spawner) thread.The spawned thread would set the exception via
reportError(Throwable). The parent would check (at certain points) for exceptions viacheckAndThrowException(). Optionally, the parent can pass itself in the constructor to be interrupted as soon as an exception occurs.final ExceptionProxy errorProxy = new ExceptionProxy(Thread.currentThread()); Thread subThread = new Thread() { public void run() { try { doSomething(); } catch (Throwable t) { errorProxy.reportError( } finally { doSomeCleanup(); } } }; subThread.start(); doSomethingElse(); errorProxy.checkAndThrowException(); doSomethingMore(); errorProxy.checkAndThrowException(); try { subThread.join(); } catch (InterruptedException e) { errorProxy.checkAndThrowException(); // restore interrupted status, if not caused by an exception Thread.currentThread().interrupt(); }
-
-
Constructor Summary
Constructors Constructor Description ExceptionProxy(Thread toInterrupt)Deprecated.Creates an exception proxy that interrupts the given thread upon report of an exception.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcheckAndThrowException()Deprecated.Checks whether an exception has been set viareportError(Throwable).voidreportError(Throwable t)Deprecated.Sets the exception and interrupts the target thread, if no other exception has occurred so far.
-
-
-
Method Detail
-
reportError
public void reportError(Throwable t)
Deprecated.Sets the exception and interrupts the target thread, if no other exception has occurred so far.The exception is only set (and the interruption is only triggered), if no other exception was set before.
- Parameters:
t- The exception that occurred
-
checkAndThrowException
public void checkAndThrowException() throws ExceptionDeprecated.Checks whether an exception has been set viareportError(Throwable). If yes, that exception if re-thrown by this method.- Throws:
Exception- This method re-throws the exception, if set.
-
-