簡體   English   中英

響應類中的com.netflix.feign NullPointerException

[英]com.netflix.feign NullPointerException in Response class

我與假客戶有問題。 我有三個通過假裝彼此通信的模塊。 它看起來像這樣:
moduleA <---假冒---> moduleB <----假冒----> moduleC
moduleC被發送到moduleB全成響應出現我的問題。 我分析了假冒的核心課程,並找到了原因。

 package feign;
  public final class Response {

  private final int status;
  private final String reason;
  private final Map<String, Collection<String>> headers;
  private final Body body;

  private Response(int status, String reason, Map<String, Collection<String>> headers, Body body) {
    checkState(status >= 200, "Invalid status code: %s", status); //my status is 200
    this.status = status;
    this.reason = checkNotNull(reason, "reason"); // my reason is unfortunatelly null
    LinkedHashMap<String, Collection<String>>
        copyOf =
        new LinkedHashMap<String, Collection<String>>();
    copyOf.putAll(checkNotNull(headers, "headers"));
    this.headers = Collections.unmodifiableMap(copyOf);
    this.body = body; //nullable
  }
}

在偽核心類的響應中,當方法checkNotNull(reason,“ reason”)被觸發時,即使響應狀態為200,也會出現NullPointerException。如何解決它?

編輯:我的假裝版本是8.1.1

EDIT2:我的tomcat版本是8.5.20

我找到了答案。 問題是由tomcat引起的。 8.0。*版禁用了響應中的原因短語,因此我不得不將其啟用(幸運的是,仍然可以,因為在9以上的版本中沒有)。 我必須編輯server.xml文件並附加到連接器sendReasonPhrase屬性。 現在看起來像這樣:

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           sendReasonPhrase="true"
           redirectPort="8443" />

是有關一個問題的更多信息, 是有關連接器屬性的更多信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM