@VisibleForTesting public void join() { assert !isRunning() : "expected not running"; // stop the timeout executor timeoutExecutor.awaitTermination(); // stop the worker threads for (WorkerThread worker: workerThreads) { worker.awaitTermination(); } // Destroy the Thread Group for the executors // TODO: Fix. #join is not place to destroy resources. try { threadGroup.destroy(); } catch (IllegalThreadStateException e) { LOG.error("ThreadGroup {} contains running threads; {}: See STDOUT", this.threadGroup, e.getMessage()); // This dumps list of threads on STDOUT. this.threadGroup.list(); } // reset the in-memory state for testing completed.clear(); rollbackStack.clear(); procedures.clear(); nonceKeysToProcIdsMap.clear(); scheduler.clear(); lastProcId.set(-1); }
returnCode=process.exitValue(); } catch (IllegalThreadStateException itsx) { logger.info("stopOrDestroyProcess: "+itsx.getMessage() +" "+((itsx.getCause()!=null) ? itsx.getCause() : "") ); Callable<Integer> callable= process::waitFor;
returnCode=process.exitValue(); } catch (IllegalThreadStateException itsx) { logger.info("stopOrDestroyProcess: "+itsx.getMessage() +" "+((itsx.getCause()!=null) ? itsx.getCause() : "") ); Callable<Integer> callable=new Callable<Integer>() {
if (LOG.isDebugEnabled() && (System.currentTimeMillis() - lastTimeDebugPrinted > 10000)) { String timeHMS = StringUtil.formatTimeHMS(System.currentTimeMillis() - startTime); LOG.debug("Command still running: " + cmd + ", msg: " + itse.getMessage() + ", elapsed: " + timeHMS); lastTimeDebugPrinted = System.currentTimeMillis();
if (LOG.isDebugEnabled() && (System.currentTimeMillis() - lastTimeDebugPrinted > 10000)) { String timeHMS = StringUtil.formatTimeHMS(System.currentTimeMillis() - startTime); LOG.debug("Command still running: " + cmd + ", msg: " + itse.getMessage() + ", elapsed: " + timeHMS); lastTimeDebugPrinted = System.currentTimeMillis();
@VisibleForTesting public void join() { assert !isRunning() : "expected not running"; // stop the timeout executor timeoutExecutor.awaitTermination(); timeoutExecutor = null; // stop the worker threads for (WorkerThread worker: workerThreads) { worker.awaitTermination(); } workerThreads = null; // Destroy the Thread Group for the executors try { threadGroup.destroy(); } catch (IllegalThreadStateException e) { LOG.error("ThreadGroup " + threadGroup + " contains running threads; " + e.getMessage()); threadGroup.list(); } finally { threadGroup = null; } // reset the in-memory state for testing completed.clear(); rollbackStack.clear(); procedures.clear(); nonceKeysToProcIdsMap.clear(); scheduler.clear(); lastProcId.set(-1); }
} catch (InterruptedException e1) { logger.error( "Process, failed [" + e.getMessage() + "]", e);
} catch (IllegalThreadStateException e) { LOG.error("ThreadGroup {} contains running threads; {}: See STDOUT", this.threadGroup, e.getMessage());
@Test public void whenCallEnsureThatContextOverloadedShouldThrowIllegalThreadStateExceptionUsingSuppliedMessage() { try { Ensure.ensureThatContext("foo", is(nullValue()), "my message"); fail(); } catch (final IllegalThreadStateException ex) { assertThat(ex.getMessage(), is("my message")); } }
@Test public void whenCallEnsureThatContextShouldThrowIllegalThreadStateException() { try { Ensure.ensureThatContext("foo", is(nullValue())); fail(); } catch (final IllegalThreadStateException ex) { assertThat(ex.getMessage(), is("illegal argument, expected: is null")); } }