I have a problem with Feign Clients. I have three modules which communicate with each other using feign. It looks somehow like this:
moduleA <---feign---> moduleB <----feign---->moduleC
My problem occurs when moduleC is sending successfull response to moduleB. I annalyzed feign-core classes and have found a cause.
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
}
}
In feign-core class Response when method checkNotNull(reason, "reason") is triggered there goes NullPointerException even though the response status is 200. How can I fix it?
EDIT: My feign version is 8.1.1
EDIT2: My tomcat version is 8.5.20
I have found the answer. Problem was caused by tomcat. Version 8.0.* disabled reason phrase in response, therefore I had to enabled it (fortunatelly it was still possible because in versions above 9 it is not). I had to edit server.xml file and append to Connector sendReasonPhrase attribute. Now it looks like this:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
sendReasonPhrase="true"
redirectPort="8443" />
Here is more about an issue and here is more about Connector attributes