/** * <p> * Throw {@code OutOfMemoryError} inside thread and * check {@code YarnUncaughtExceptionHandler} instance * <p> * Used {@code ExitUtil} class to avoid jvm exit through * {@code Runtime.getRuntime().halt(-1)} * * @throws InterruptedException */ @Test public void testUncaughtExceptionHandlerWithOutOfMemoryError() throws InterruptedException { ExitUtil.disableSystemHalt(); final YarnUncaughtExceptionHandler spyOomHandler = spy(exHandler); final OutOfMemoryError oomError = new OutOfMemoryError("out-of-memory-error"); final Thread oomThread = new Thread(new Runnable() { @Override public void run() { throw oomError; } }); oomThread.setUncaughtExceptionHandler(spyOomHandler); assertSame(spyOomHandler, oomThread.getUncaughtExceptionHandler()); oomThread.start(); oomThread.join(); verify(spyOomHandler).uncaughtException(oomThread, oomError); } }
/** * <p> * Throw {@code OutOfMemoryError} inside thread and * check {@code YarnUncaughtExceptionHandler} instance * <p> * Used {@code ExitUtil} class to avoid jvm exit through * {@code Runtime.getRuntime().halt(-1)} * * @throws InterruptedException */ @Test public void testUncaughtExceptionHandlerWithOutOfMemoryError() throws InterruptedException { ExitUtil.disableSystemHalt(); final YarnUncaughtExceptionHandler spyOomHandler = spy(exHandler); final OutOfMemoryError oomError = new OutOfMemoryError("out-of-memory-error"); final Thread oomThread = new Thread(new Runnable() { @Override public void run() { throw oomError; } }); oomThread.setUncaughtExceptionHandler(spyOomHandler); assertSame(spyOomHandler, oomThread.getUncaughtExceptionHandler()); oomThread.start(); oomThread.join(); verify(spyOomHandler).uncaughtException(oomThread, oomError); } }
/** * <p> * Throw {@code OutOfMemoryError} inside thread and * check {@code YarnUncaughtExceptionHandler} instance * <p> * Used {@code ExitUtil} class to avoid jvm exit through * {@code Runtime.getRuntime().halt(-1)} * * @throws InterruptedException */ @Test public void testUncaughtExceptionHandlerWithOutOfMemoryError() throws InterruptedException { ExitUtil.disableSystemHalt(); final YarnUncaughtExceptionHandler spyOomHandler = spy(exHandler); final OutOfMemoryError oomError = new OutOfMemoryError("out-of-memory-error"); final Thread oomThread = new Thread(new Runnable() { @Override public void run() { throw oomError; } }); oomThread.setUncaughtExceptionHandler(spyOomHandler); assertSame(spyOomHandler, oomThread.getUncaughtExceptionHandler()); oomThread.start(); oomThread.join(); verify(spyOomHandler).uncaughtException(oomThread, oomError); } }