@Nullable
    static <T> T mapCurrent(
            Function<? super ServiceRequestContext, T> mapper,
            @Nullable Supplier<@Nullable T> defaultValueSupplier) {

        final ServiceRequestContext ctx = currentOrNull();
        if (ctx != null) {
            return mapper.apply(ctx);
        }

        final ClientRequestContext clientRequestContext = ClientRequestContext.currentOrNull();
        if (clientRequestContext != null) {
            throw new IllegalStateException(
                    "The current context is not a server-side context and does not have a root " +
                    "which means that the context is not invoked by a server request. ctx: " +
                    clientRequestContext);
        }

        if (defaultValueSupplier != null) {
            return defaultValueSupplier.get();
        }

        return null;
    }
Maps the server-side context of the {@link Request} that is being handled in the current thread.

@param mapper the {@link Function} that maps the {@link ServiceRequestContext}
@param defaultValueSupplier the {@link Supplier} that provides the value when the context is unavailable
                            in the current thread. If {@code null}, the {@code null} will be returned
                            when the context is unavailable in the current thread.
@throws IllegalStateException if the current context is not a {@link ServiceRequestContext}.
core/src/main/java/com/linecorp/armeria/server/ServiceRequestContext.java