private static HttpResponse<String>
    sendResubmitRequest(HttpClient client, HttpRequest request) throws IOException, InterruptedException {
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        if (log.isDebugEnabled()) {
            log.debug("Resubmit request: {}, response: {}", request, response);
            log.debug("Response Headers: {}", response.headers().map());
        }
        if (response.statusCode() == AUTHFAIL) {
            log.debug("processing authfail");
            var cookieManager = (CookieManager) client.cookieHandler().get();
            cookieStreamFromHeader(response.headers().allValues(SET_COOKIE))
                    .forEach(cookie -> cookieManager.getCookieStore().add(request.uri(), cookie));
            response = client.send(request, HttpResponse.BodyHandlers.ofString());
            if (log.isDebugEnabled()) {
                log.debug("Resubmit request(authfail): {}, response: {}", request, response);
                log.debug("Response Headers(authfail): {}", response.headers().map());
            }
        }
        return response;
    }
flash cookie is preserved here

@param request
@param response
@param path
@param paramValues
support/jakarta-ee/src/main/java/org/apache/shiro/ee/filters/FormResubmitSupport.java