private void checkConfiguration(StandardServer server,
                                    Service expectedService, Connector expectedConnector,
                                    Engine expectedEngine, StandardHost expectedHost, Context expectedContext) {

        // Check if Catalina base and home directories have not been changed.
        final File expectedBaseDir = config.baseDir().toFile();
        if (!Objects.equals(server.getCatalinaBase(), expectedBaseDir) ||
            !Objects.equals(server.getCatalinaHome(), expectedBaseDir)) {
            throw new TomcatServiceException("A configurator should never change the Catalina base and home.");
        }

        // Check if the server's port has not been changed.
        if (server.getPort() != EMBEDDED_TOMCAT_PORT) {
            throw new TomcatServiceException("A configurator should never change the port of the server.");
        }

        // Check if the default service has not been removed and a new service has not been added.
        final Service[] services = server.findServices();
        if (services == null || services.length != 1 || services[0] != expectedService) {
            throw new TomcatServiceException(
                    "A configurator should never remove the default service or add a new service.");
        }

        // Check if the name of the default service has not been changed.
        if (!config.serviceName().equals(expectedService.getName())) {
            throw new TomcatServiceException(
                    "A configurator should never change the name of the default service.");
        }

        // Check if the default connector has not been removed
        final Connector[] connectors = expectedService.findConnectors();
        if (connectors == null || Arrays.stream(connectors).noneMatch(c -> c == expectedConnector)) {
            throw new TomcatServiceException("A configurator should never remove the default connector.");
        }

        // Check if the engine has not been changed.
        final Container actualEngine = TomcatUtil.engine(expectedService, expectedHost.getName());
        if (actualEngine != expectedEngine) {
            throw new TomcatServiceException(
                    "A configurator should never change the engine of the default service.");
        }

        // Check if the engine's name has not been changed.
        if (!config.engineName().equals(expectedEngine.getName())) {
            throw new TomcatServiceException(
                    "A configurator should never change the name of the default engine.");
        }

        // Check if the default realm has not been changed.
        if (expectedEngine.getRealm() != config.realm()) {
            throw new TomcatServiceException("A configurator should never change the default realm.");
        }

        // Check if the default host has not been removed.
        final Container[] engineChildren = expectedEngine.findChildren();
        if (engineChildren == null || Arrays.stream(engineChildren).noneMatch(c -> c == expectedHost)) {
            throw new TomcatServiceException("A configurator should never remove the default host.");
        }

        // Check if the default context has not been removed.
        final Container[] contextChildren = expectedHost.findChildren();
        if (contextChildren == null || Arrays.stream(contextChildren).noneMatch(c -> c == expectedContext)) {
            throw new TomcatServiceException("A configurator should never remove the default context.");
        }

        // Check if the docBase of the default context has not been changed.
        if (!config.docBase().toString().equals(expectedContext.getDocBase())) {
            throw new TomcatServiceException(
                    "A configurator should never change the docBase of the default context.");
        }
    }
See {@link StandardServer#await()} for more information about this magic number (-2),
which is used for an embedded Tomcat server that manages its life cycle manually.
tomcat10/src/main/java/com/linecorp/armeria/server/tomcat/ManagedConnectorFactory.java