use of java.util.concurrent.RejectedExecutionException in project wildfly by wildfly.
the class JobOperatorService method stop.
@Override
public void stop(final StopContext context) {
// Remove the server activity
suspendControllerInjector.getValue().unRegisterActivity(serverActivity);
final ExecutorService service = executorInjector.getValue();
final Runnable task = () -> {
// Should already be stopped, but just to be safe we'll make one more attempt
serverActivity.stopRunningJobs(false);
batchEnvironment = null;
classLoader = null;
context.complete();
};
try {
service.execute(task);
} catch (RejectedExecutionException e) {
task.run();
} finally {
context.asynchronous();
}
}
use of java.util.concurrent.RejectedExecutionException in project wildfly by wildfly.
the class AbstractResourceAdapterDeploymentService method stopAsync.
protected void stopAsync(final StopContext context, final String deploymentName, final ServiceName serviceName) {
ExecutorService executorService = getLifecycleExecutorService();
Runnable r = new Runnable() {
@Override
public void run() {
try {
DEPLOYMENT_CONNECTOR_LOGGER.debugf("Stopping service %s", serviceName);
WritableServiceBasedNamingStore.pushOwner(serviceName);
unregisterAll(deploymentName);
} finally {
WritableServiceBasedNamingStore.popOwner();
context.complete();
}
}
};
try {
executorService.execute(r);
} catch (RejectedExecutionException e) {
r.run();
} finally {
context.asynchronous();
}
}
use of java.util.concurrent.RejectedExecutionException in project wildfly by wildfly.
the class ResourceAdapterDeploymentService method cleanupStartAsync.
// TODO this could be replaced by the superclass method if there is no need for the TCCL change and push/pop owner
// The stop() call doesn't do that so it's probably not needed
private void cleanupStartAsync(final StartContext context, final String deploymentName, final Throwable cause, final ServiceName duServiceName, final ClassLoader toUse) {
ExecutorService executorService = getLifecycleExecutorService();
Runnable r = new Runnable() {
@Override
public void run() {
ClassLoader old = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WritableServiceBasedNamingStore.pushOwner(duServiceName);
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(toUse);
unregisterAll(deploymentName);
} finally {
try {
context.failed(ConnectorLogger.ROOT_LOGGER.failedToStartRaDeployment(cause, deploymentName));
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
WritableServiceBasedNamingStore.popOwner();
}
}
}
};
try {
executorService.execute(r);
} catch (RejectedExecutionException e) {
r.run();
} finally {
context.asynchronous();
}
}
use of java.util.concurrent.RejectedExecutionException in project distributedlog by twitter.
the class TestSafeQueueingFuturePool method testRejectedFailure.
@Test
public void testRejectedFailure() throws Exception {
TestFuturePool<Void> pool = new TestFuturePool<Void>();
final AtomicBoolean result = new AtomicBoolean(false);
pool.executor.shutdown();
final CountDownLatch latch = new CountDownLatch(1);
Future<Void> future = pool.wrapper.apply(new Function0<Void>() {
public Void apply() {
result.set(true);
latch.countDown();
return null;
}
});
try {
Await.result(future);
fail("should have thrown");
} catch (RejectedExecutionException ex) {
}
assertFalse(result.get());
pool.wrapper.close();
latch.await();
assertTrue(result.get());
pool.shutdown();
}
use of java.util.concurrent.RejectedExecutionException in project undertow by undertow-io.
the class Connectors method executeRootHandler.
public static void executeRootHandler(final HttpHandler handler, final HttpServerExchange exchange) {
try {
exchange.setInCall(true);
handler.handleRequest(exchange);
exchange.setInCall(false);
boolean resumed = exchange.runResumeReadWrite();
if (exchange.isDispatched()) {
if (resumed) {
UndertowLogger.REQUEST_LOGGER.resumedAndDispatched();
exchange.setStatusCode(500);
exchange.endExchange();
return;
}
final Runnable dispatchTask = exchange.getDispatchTask();
Executor executor = exchange.getDispatchExecutor();
exchange.setDispatchExecutor(null);
exchange.unDispatch();
if (dispatchTask != null) {
executor = executor == null ? exchange.getConnection().getWorker() : executor;
try {
executor.execute(dispatchTask);
} catch (RejectedExecutionException e) {
UndertowLogger.REQUEST_LOGGER.debug("Failed to dispatch to worker", e);
exchange.setStatusCode(StatusCodes.INTERNAL_SERVER_ERROR);
exchange.endExchange();
}
}
} else if (!resumed) {
exchange.endExchange();
}
} catch (Throwable t) {
exchange.putAttachment(DefaultResponseListener.EXCEPTION, t);
exchange.setInCall(false);
if (!exchange.isResponseStarted()) {
exchange.setStatusCode(StatusCodes.INTERNAL_SERVER_ERROR);
}
if (t instanceof IOException) {
UndertowLogger.REQUEST_IO_LOGGER.ioException((IOException) t);
} else {
UndertowLogger.REQUEST_LOGGER.undertowRequestFailed(t, exchange);
}
exchange.endExchange();
}
}
Aggregations