diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalAnalyzerImpl.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalAnalyzerImpl.java index 73df85a558..5fddd1d7d8 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalAnalyzerImpl.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalAnalyzerImpl.java @@ -16,12 +16,15 @@ */ package org.apache.activemq.artemis.utils.critical; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ConcurrentModificationException; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.activemq.artemis.core.server.ActiveMQScheduledComponent; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.collections.ConcurrentHashSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,11 +51,28 @@ public class CriticalAnalyzerImpl implements CriticalAnalyzer { * issues and won't be able to shutdown the server or halt the VM */ this.scheduledComponent = new ActiveMQScheduledComponent(null, null, checkTimeNanoSeconds, TimeUnit.NANOSECONDS, false) { + @Override public void run() { logger.trace("Checking critical analyzer"); check(); } + + @Override + protected ActiveMQThreadFactory getThreadFactory() { + return new ActiveMQThreadFactory("CriticalAnalyzer", "Critical-Analyzer-", true, getThisClassLoader()); + } + + private ClassLoader getThisClassLoader() { + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public ClassLoader run() { + return CriticalAnalyzerImpl.this.getClass().getClassLoader(); + } + }); + + } + }; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index 20690cb835..b01a3ca759 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -689,7 +689,13 @@ public class ActiveMQServerImpl implements ActiveMQServer { nodeManager = createNodeManager(configuration.getNodeManagerLockLocation(), false); - nodeManager.start(); + try { + nodeManager.start(); + } catch (Exception e) { + //if there's an error here, ensure remaining threads shut down + stopTheServer(true); + throw e; + } ActiveMQServerLogger.LOGGER.serverStarting((haPolicy.isBackup() ? "backup" : "live"), configuration); diff --git a/tests/smoke-tests/pom.xml b/tests/smoke-tests/pom.xml index e7fd3e7db0..29607ee4d7 100644 --- a/tests/smoke-tests/pom.xml +++ b/tests/smoke-tests/pom.xml @@ -1281,7 +1281,33 @@ - + + test-compile + create-jdbc-bad-driver + + create + + + amq + admin + admin + false + true + ${basedir}/target/jdbc-bad-driver + + --http-host + ${sts-http-host} + --http-port + 8161 + --shared-store + --jdbc + --jdbc-connection-url + tcp://noexist + --jdbc-driver-class-name + badDriver + + + diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jdbc/JdbcStartupTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jdbc/JdbcStartupTest.java new file mode 100644 index 0000000000..f77ee542a4 --- /dev/null +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jdbc/JdbcStartupTest.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.artemis.tests.smoke.jdbc; + +import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase; +import org.junit.Assert; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +public class JdbcStartupTest extends SmokeTestBase { + + protected static final String SERVER_NAME = "jdbc-bad-driver"; + + @Test + public void startupBadJdbcConnectionTest() throws Exception { + + Integer exitVal = -1; + Process p = startServer(SERVER_NAME, 0, 0); + try { + p.waitFor(10, TimeUnit.SECONDS); + exitVal = p.exitValue(); + } catch (Exception e) { + Assert.fail(); + } + + Assert.assertEquals(0, (long) exitVal); + } +}