OpenFeign/feign

java.lang.IllegalArgumentException: Deflate Content-Encoding is not supported by feign-hc5

Open

#2.460 aberto em 27 de jun. de 2024

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)Java (1.911 forks)batch import
help wantedwaiting for feedback

Métricas do repositório

Stars
 (9.070 stars)
Métricas de merge de PR
 (Mesclagem média 3d 8h) (59 fundiu PRs em 30d)

Description

When we upgraded to spring-boot-dependencies-3.3.0, we also upgrade the spring-cloud according to https://spring.io/blog/2024/05/31/spring-cloud-2023-0-2-oss-and-2022-0-7-enterprise-have-been-released, Then my service met error "Caused by: java.lang.IllegalArgumentException: Deflate Content-Encoding is not supported by feign-hc5"

Here is some finding of troubleshooting:

As we set spring.cloud.openfeign.compression.request.enabled=true, so the FeignContentGzipEncodingInterceptor(spring-cloud-openfeign-core-4.1.2) is enabled too

public class FeignContentGzipEncodingInterceptor extends BaseRequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        if (requiresCompression(template)) {
		addHeader(template, HttpEncoding.CONTENT_ENCODING_HEADER, HttpEncoding.GZIP_ENCODING,
					HttpEncoding.DEFLATE_ENCODING);
	}
    }
}

If the compression condition matched, it will add fixed header(Content-Encoding: gzip,deflate), but after the PR https://github.com/OpenFeign/feign/pull/2247, it will throw IllegalArgumentException once 'deflate' exists in header 'Content-Encoding'

if (headerName.equalsIgnoreCase(Util.CONTENT_ENCODING)) {
        isGzip = headerEntry.getValue().stream().anyMatch(Util.ENCODING_GZIP::equalsIgnoreCase);
        boolean isDeflate =
            headerEntry.getValue().stream().anyMatch(Util.ENCODING_DEFLATE::equalsIgnoreCase);
        if (isDeflate) {
          // DeflateCompressingEntity not available in hc5 yet
          throw new IllegalArgumentException(
              "Deflate Content-Encoding is not supported by feign-hc5");
        }
      }

I think it is incompatible change, @fbus or term, Please take a look on it

Guia do colaborador