public JettyService build() {
        // Make a copy of the properties that's used in `serverFactory` so that any further modification of
        // this builder doesn't affect the built server.
        final Boolean dumpAfterStart = this.dumpAfterStart;
        final Boolean dumpBeforeStop = this.dumpBeforeStop;
        final Long stopTimeoutMillis = this.stopTimeoutMillis;
        final Handler handler = this.handler;
        final RequestLog requestLog = this.requestLog;
        final Map<String, Object> attrs = this.attrs.build();
        final List<Bean> beans = this.beans.build();
        final List<Handler.Singleton> handlerWrappers = this.handlerWrappers.build();
        final List<EventListener> eventListeners = this.eventListeners.build();
        final List<Consumer<? super Server>> customizers = this.customizers.build();

        final Function<BlockingTaskExecutor, Server> serverFactory = new Function<>() {

            private final ReentrantShortLock lock = new ReentrantShortLock();
            @Nullable
            private Server server;

            @Override
            public Server apply(BlockingTaskExecutor blockingTaskExecutor) {
                lock.lock();
                try {
                    if (server != null) {
                        return server;
                    }
                    server = new Server(new ArmeriaThreadPool(blockingTaskExecutor));

                    if (dumpAfterStart != null) {
                        server.setDumpAfterStart(dumpAfterStart);
                    }
                    if (dumpBeforeStop != null) {
                        server.setDumpBeforeStop(dumpBeforeStop);
                    }
                    if (stopTimeoutMillis != null) {
                        server.setStopTimeout(stopTimeoutMillis);
                    }

                    if (handler != null) {
                        server.setHandler(handler);
                    }
                    if (requestLog != null) {
                        server.setRequestLog(requestLog);
                    }

                    handlerWrappers.forEach(server::insertHandler);
                    attrs.forEach(server::setAttribute);
                    beans.forEach(bean -> {
                        final Boolean managed = bean.isManaged();
                        if (managed == null) {
                            server.addBean(bean.bean());
                        } else {
                            server.addBean(bean.bean(), managed);
                        }
                    });

                    eventListeners.forEach(server::addEventListener);

                    customizers.forEach(c -> c.accept(server));
                    return server;
                } finally {
                    lock.unlock();
                }
            }
        };

        final Consumer<Server> postStopTask = server -> {
            try {
                JettyService.logger.info("Destroying an embedded Jetty: {}", server);
                server.destroy();
            } catch (Exception e) {
                JettyService.logger.warn("Failed to destroy an embedded Jetty: {}", server, e);
            }
        };
        return new JettyService(hostname, serverFactory, postStopTask);
    }
Returns a newly-created {@link JettyService} based on the properties of this builder.
jetty/jetty12/src/main/java/com/linecorp/armeria/server/jetty/JettyServiceBuilder.java