private void checkNotStarted() { if (started) { throw new IllegalThreadStateException("Thread already started"); } }
@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); }
public int exitValue() { synchronized (exitValueMutex) { if (exitValue == null) { throw new IllegalThreadStateException("Process has not yet terminated: " + pid); } return exitValue; } }
@Test public void whenCallEnsureThatContextOverloadedShouldThrowIllegalThreadStateExceptionUsingSuppliedMessage() { try { Ensure.ensureThatContext("foo", is(nullValue()), "my message"); fail(); } catch (final IllegalThreadStateException ex) { assertThat(ex.getMessage(), is("my message")); } }
private void checkQueueLength() { if (connectionExecutor.getQueue().size() > queuewarninglimit) { logger.warn(new IllegalThreadStateException("connectionordered channel handler `queue size: " + connectionExecutor.getQueue().size() + " exceed the warning limit number :" + queuewarninglimit)); } } }
@Test public void whenCallEnsureThatContextShouldThrowIllegalThreadStateException() { try { Ensure.ensureThatContext("foo", is(nullValue())); fail(); } catch (final IllegalThreadStateException ex) { assertThat(ex.getMessage(), is("illegal argument, expected: is null")); } }
private void checkQueueLength() { if (connectionExecutor.getQueue().size() > queuewarninglimit) { logger.warn(new IllegalThreadStateException("connectionordered channel handler `queue size: " + connectionExecutor.getQueue().size() + " exceed the warning limit number :" + queuewarninglimit)); } } }
/** * Adds a {@code ThreadGroup} to this thread group. * * @param g ThreadGroup to add * @throws IllegalThreadStateException if this group has been destroyed already */ private void add(ThreadGroup g) throws IllegalThreadStateException { synchronized (groups) { if (isDestroyed) { throw new IllegalThreadStateException(); } groups.add(g); } }
/** * Called by the Thread constructor. */ final void addThread(Thread thread) throws IllegalThreadStateException { synchronized (threadRefs) { if (isDestroyed) { throw new IllegalThreadStateException(); } threadRefs.add(new WeakReference<Thread>(thread)); } }
protected RollbackStateLocal getRollbackStateLocal() { RollbackStateLocal rollbackStateLocal = RollbackStateLocal.getRollbackStateLocal(); if (rollbackStateLocal == null) { throw new IllegalThreadStateException("Unable to perform ActivityStateManager operation, as the RollbackStateLocal instance is not set on the current thread! ActivityStateManager methods may not be called outside the scope of workflow execution."); } return rollbackStateLocal; }
public CallStackItem pop() { try { CallStackItem result = callStack[--callStackTop]; result.clear(); // clear for GC return result; } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalThreadStateException(); } }
@Override public RAMDataAccess create(long bytes) { if (segments.length > 0) throw new IllegalThreadStateException("already created"); setSegmentSize(segmentSizeInBytes); ensureCapacity(Math.max(10 * 4, bytes)); return this; }
@Override public RAMIntDataAccess create(long bytes) { if (segments.length > 0) throw new IllegalThreadStateException("already created"); setSegmentSize(segmentSizeInBytes); ensureCapacity(Math.max(10 * 4, bytes)); return this; }
@Override public MMapDataAccess create(long bytes) { if (!segments.isEmpty()) { throw new IllegalThreadStateException("already created"); } initRandomAccessFile(); bytes = Math.max(10 * 4, bytes); setSegmentSize(segmentSizeInBytes); ensureCapacity(bytes); return this; }
synchronized (groups) { if (isDestroyed) { throw new IllegalThreadStateException( "Thread group was already destroyed: " + (this.name != null ? this.name : "n/a")); throw new IllegalThreadStateException( "Thread group still contains threads: " + (this.name != null ? this.name : "n/a"));
private void wait(final ConnectSubscriber subscriber) { final ConnectListener connectListener = new ConnectListener(subscriber); //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (connectListener) { FileDownloader.getImpl().bindService(connectListener); if (!connectListener.isFinished()) { if (Thread.currentThread() == Looper.getMainLooper().getThread()) { throw new IllegalThreadStateException("Sorry, FileDownloader can not block the " + "main thread, because the system is also callbacks " + "ServiceConnection#onServiceConnected method in the main thread."); } try { connectListener.wait(200 * 1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }
throw new IllegalThreadStateException("Group already destroyed");
@Test public void shouldReturnTrueWhenAProcessIsRunning(){ Process process = getMockedProcess(mock(OutputStream.class)); when(process.exitValue()).thenThrow(new IllegalThreadStateException()); ProcessWrapper processWrapper = new ProcessWrapper(process, "", "", inMemoryConsumer(), "utf-8", null); assertThat(processWrapper.isRunning(), is(true)); }
if (!waitingThread.interruptedByConnectionPool) { LOG.debug("Interrupted while waiting for connection", e); throw new IllegalThreadStateException( "Interrupted while waiting in MultiThreadedHttpConnectionManager");
(rs == SHUTDOWN && firstTask == null)) { if (t.isAlive()) // precheck that t is startable throw new IllegalThreadStateException(); workers.add(w); int s = workers.size();