MCPcopy Create free account
hub / github.com/apache/tomcat / stop

Method stop

java/org/apache/catalina/startup/Catalina.java:930–965  ·  view source on GitHub ↗

Stop an existing server instance.

()

Source from the content-addressed store, hash-verified

928 * Stop an existing server instance.
929 */
930 public void stop() {
931
932 try {
933 // Remove the ShutdownHook first so that server.stop()
934 // doesn't get invoked twice
935 if (useShutdownHook) {
936 Runtime.getRuntime().removeShutdownHook(shutdownHook);
937
938 // If JULI is being used, re-enable JULI's shutdown to ensure
939 // log messages are not lost
940 LogManager logManager = LogManager.getLogManager();
941 if (logManager instanceof ClassLoaderLogManager) {
942 ((ClassLoaderLogManager) logManager).setUseShutdownHook(true);
943 }
944 }
945 } catch (Throwable t) {
946 ExceptionUtils.handleThrowable(t);
947 // This will fail on JDK 1.2. Ignoring, as Tomcat can run
948 // fine without the shutdown hook.
949 }
950
951 // Shut down the server
952 try {
953 Server s = getServer();
954 LifecycleState state = s.getState();
955 if (LifecycleState.STOPPING_PREP.compareTo(state) <= 0 && LifecycleState.DESTROYED.compareTo(state) >= 0) {
956 // Nothing to do. stop() was already called
957 } else {
958 s.stop();
959 s.destroy();
960 }
961 } catch (LifecycleException e) {
962 log.error(sm.getString("catalina.stopError"), e);
963 }
964
965 }
966
967
968 /**

Callers 1

startMethod · 0.95

Calls 9

handleThrowableMethod · 0.95
getServerMethod · 0.95
getStateMethod · 0.65
compareToMethod · 0.65
stopMethod · 0.65
destroyMethod · 0.65
errorMethod · 0.65
getStringMethod · 0.65
setUseShutdownHookMethod · 0.45

Tested by

no test coverage detected