RestOperation交换拒绝cookie

时间:2017-09-05 10:51:55

标签: java rest cookies

我有一个类来检查REST接口的运行状况。它工作得很好,但我的日志文件中充满了这些警告:

2017-08-23 03:59:58.707  WARN 1849 --- [io-13811-exec-5] o.a.h.c.protocol.ResponseProcessCookies  : Cookie rejected [JSESSIONID="14747303A2F23D4BE6DBAE0F282DEA94", version:0, domain:dealersearch.....com, path:/DCRMBroker/, expiry:null] Illegal 'path' attribute "/DCRMBroker/". Path of origin: "/system/healthcheck.jsp"

似乎请求不接受任何cookie。我不明白发生了什么,以及如何接受它们来绕过大量的日志消息。

我的健康检查课程:

package com......commons.health;

import com.....commons.health.HealthResult.Health;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestOperations;

public abstract class RestHealthCheck extends HealthCheck {
private static final Logger LOGGER =     LoggerFactory.getLogger(RestHealthCheck.class);

public RestHealthCheck() {}

public abstract String getUrl();

public abstract RestOperations getRestOperations();

public HealthResult getHealthResult() {
    HealthResult result = new HealthResult();
    result.setName(this.getName());
    result.setHealth(Health.HEALTHY);
    result.setMessage((String)null);
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);
    HttpEntity entity = new HttpEntity(headers);

    try {
        this.getRestOperations().exchange(this.getUrl(), HttpMethod.HEAD, entity, String.class, new Object[0]);
    } catch (Exception var5) {
        LOGGER.trace("Health check failed", var5);
        result.setHealth(Health.UNHEALTHY);
        result.setMessage(var5.getMessage());
    }

    return result;
}
}

1 个答案:

答案 0 :(得分:1)

请求网址http://server.example.com/system/healthcheck.jsp,并且响应中包含为网址http://server.example.com/DCRMBroker/定义的Cookie。

网址不同,名副其实的客户端应拒绝此处发生的导致日志的内容。你提供的信息不足以确定谁是罪魁祸首。它可能是JSP页面设置错误的cookie,它可能是服务器上的转发规则,因此JSP页面在内部转发到不同的资源而不更改响应中的路径。它也可能在您的客户端上发生某种重定向导致这种影响。

也许我的解释可以帮助您追踪原因。如果您有什么需要,可以解决这个问题。如果它是另一方的东西,你可能会与他们联系,以便解决这个问题。或者,您可以检查您的客户端是否可以关闭此特定情况的警告,以便您的日志再次变得平静。

相关问题