mockserver-client-java/src/main/java/org/mockserver/client/MockServerClient.java
public Future<MockServerClient> stop(boolean ignoreFailure) {
        getMockServerEventBus().publish(EventType.STOP);
        removeMockServerEventBus();
        CompletableFuture<MockServerClient> stopFuture = new CompletableFuture<>();
        new Scheduler.SchedulerThreadFactory("ClientStop").newThread(() -> {
            try {
                sendRequest(request().withMethod("PUT").withPath(calculatePath("stop")));
                if (isRunning()) {
                    for (int i = 0; isRunning() && i < 50; i++) {
                        TimeUnit.MILLISECONDS.sleep(5);
                    }
                }
            } catch (RejectedExecutionException ree) {
                MOCK_SERVER_LOGGER.logEvent(
                    new LogEntry()
                        .setLogLevel(TRACE)
                        .setMessageFormat("request rejected while closing down, logging in case due other error " + ree)
                );
            } catch (Exception e) {
                if (!ignoreFailure) {
                    MOCK_SERVER_LOGGER.logEvent(
                        new LogEntry()
                            .setLogLevel(WARN)
                            .setMessageFormat("failed to send stop request to MockServer " + e.getMessage())
                    );
                }
            }
            if (!eventLoopGroup.isShuttingDown()) {
                eventLoopGroup.shutdownGracefully();
            }
            stopFuture.complete(clientClass.cast(this));
        }).start();
        return stopFuture;
    }
/**
     * Stop MockServer gracefully (only support for Netty version, not supported for WAR version)
     */
Stop MockServer gracefully (only support for Netty version, not supported for WAR version)
Stop MockServer gracefully ( only support for Netty version not supported for WAR version )
public Future<MockServerClient> stop(boolean ignoreFailure) {
        getMockServerEventBus().publish(EventType.STOP);
        removeMockServerEventBus();
        CompletableFuture<MockServerClient> stopFuture = new CompletableFuture<>();
        new Scheduler.SchedulerThreadFactory("ClientStop").newThread(() -> {
            try {
                sendRequest(request().withMethod("PUT").withPath(calculatePath("stop")));
                if (isRunning()) {
                    for (int i = 0; isRunning() && i < 50; i++) {
                        TimeUnit.MILLISECONDS.sleep(5);
                    }
                }
            } catch (RejectedExecutionException ree) {
                MOCK_SERVER_LOGGER.logEvent(
                    new LogEntry()
                        .setLogLevel(TRACE)
                        .setMessageFormat("request rejected while closing down, logging in case due other error " + ree)
                );
            } catch (Exception e) {
                if (!ignoreFailure) {
                    MOCK_SERVER_LOGGER.logEvent(
                        new LogEntry()
                            .setLogLevel(WARN)
                            .setMessageFormat("failed to send stop request to MockServer " + e.getMessage())
                    );
                }
            }
            if (!eventLoopGroup.isShuttingDown()) {
                eventLoopGroup.shutdownGracefully();
            }
            stopFuture.complete(clientClass.cast(this));
        }).start();
        return stopFuture;
    }
public Future < MockServerClient > stop ( boolean ignoreFailure ) { getMockServerEventBus ( ) . publish ( EventType . STOP ) ; removeMockServerEventBus ( ) ; CompletableFuture < MockServerClient > stopFuture = new CompletableFuture < > ( ) ; new Scheduler . SchedulerThreadFactory ( "ClientStop" ) . newThread ( ( ) -> { try { sendRequest ( request ( ) . withMethod ( "PUT" ) . withPath ( calculatePath ( "stop" ) ) ) ; if ( isRunning ( ) ) { for ( int i = 0 ; isRunning ( ) && i < 50 ; i ++ ) { TimeUnit . MILLISECONDS . sleep ( 5 ) ; } } } catch ( RejectedExecutionException ree ) { MOCK_SERVER_LOGGER . logEvent ( new LogEntry ( ) . setLogLevel ( TRACE ) . setMessageFormat ( "request rejected while closing down, logging in case due other error " + ree ) ) ; } catch ( Exception e ) { if ( ! ignoreFailure ) { MOCK_SERVER_LOGGER . logEvent ( new LogEntry ( ) . setLogLevel ( WARN ) . setMessageFormat ( "failed to send stop request to MockServer " + e . getMessage ( ) ) ) ; } } if ( ! eventLoopGroup . isShuttingDown ( ) ) { eventLoopGroup . shutdownGracefully ( ) ; } stopFuture . complete ( clientClass . cast ( this ) ) ; } ) . start ( ) ; return stopFuture ; }
Stop MockServer gracefully (only support for Netty version, not supported for WAR version)
Stop MockServer gracefully ( only support for Netty version not supported for WAR version )