-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feign compression is not working because of missing ApacheHttpClient bean #2462
Comments
Sorry I needed to refresh my brain on this issue. The |
@ryanjbaxter So far understood. You explained what the code is doing. But what does it mean in relation to handle this problem? Can we do something as long as this problem is not solved? And is there a plan to provide a bugfix for it? Is there for example a possibility inside the GzipEncodingAutoConfiguration's to only expect the ApacheHttpClient bean if Ribbon is not available? In general it's hard to understand that one cannot use some feign compression because he/she is using some Ribbon/Eureka. |
By default feign uses |
We default in other places to apache http client, I don't see why we couldn't here. |
Hmm, my bad, there is separate configuration if ribbon is used, and it looks like it is the default |
The gzip autoconfig should also be after |
@spencergibb Are your comments related to my answer? Do you give us some hints, what to do? Sorry but it is really difficult to follow such thought like comments without context. Therefore it would be really really helpful if you could give some more context so that one who is not living inside that code the whole day is understanding what you are exactly talking about. |
Line 42 in 6c52269
needs to also have |
Yeah the reason this does not work when using Ribbon is because @gbtec-ingogriebsch for now you can try and create your own configuration class which returns a |
@ryanjbaxter I followed your suggestion and did the following... @Configuration
@EnableConfigurationProperties(FeignClientEncodingProperties.class)
@ConditionalOnProperty(value = "feign.compression.response.enabled", matchIfMissing = false)
public class FeignAcceptGzipEncodingConfiguration {
@Bean
public FeignAcceptGzipEncodingInterceptor feignAcceptGzipEncodingInterceptor(FeignClientEncodingProperties properties) {
return new FeignAcceptGzipEncodingInterceptor(properties) {
};
}
} The corresponding configuration look like the following... feign:
compression:
request:
enabled: true
mime-types:
- application/json
min-request-size: 2048
response:
enabled: true The other side (running boot app using tomcat) is configured the following way... server:
port: 0
tomcat:
uri-encoding: UTF-8
compression:
enabled: true
mime-types:
- application/json
min-response-size: 2048 If I add the configuration classes to the project and configure the Feign compression like shown above the beans are created on startup and triggered if I execute a call through Feign. The problem is that the call results in the following exception: 2017-11-29 21:08:42.069 WARN [biccloud-custom-apigateway,406313c55480f8d9,406313c55480f8d9,true] 10892 ---
[io-30000-exec-2] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: feign.codec.DecodeException:
JSON parse error: Illegal character ((CTRL-CHAR, code 31)):
only regular white space (\r, \n, \t) is allowed between tokens;
nested exception is com.fasterxml.jackson.core.JsonParseException:
Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
at [Source: java.io.PushbackInputStream@6f37ab7d; line: 1, column: 2] After searching a little bit I stumbled about the following blog entry: The blog entry is explaining how to enable compression on Feign. It's also explaining that one is getting the error shown above and is again pointing to the following git page: This page is explaining that - if you face that problem - you need to have an ApacheHttpClient! That's the current state... Looks a little bit like we are spinning in a circle here... Or do I understand something wrong? |
@ryanjbaxter Would like to ask about the further plan regarding this bug. Has this any priority for you atm? And do you know about another workaround? |
Sorry @gbtec-ingogriebsch this fell off my radar. I will try and look into it this week. I need to refresh my brain on what was wrong again. |
@ryanjbaxter Because I don't know another way, I would like to politely repeat my request about the status of this bug ticket. |
Again sorry for taking so long to get to this but I think I have a solution for you. In addition to the
|
* feign compression configuration fixes. Fixes #2462
As already discussed in #1580 it looks like the Feign compression is not working because the auto configuration preparing the gzip interceptors expects a bean of type ApacheHttpClient which is not available in the application context.
If we add a bean of type ApacheHttpClient to the application context (without configuring the object in any way) the auto configuration is triggering and the interceptors are available (and will probably trigger). But now the call to the server side is broken because of
The project is running under Spring Boot 1.5.8 and Spring Cloud Dalston.SR4. We are using the following dependencies:
We don't know if we are missing something that would easily solve the problem. If we have a look at the classpath (through the IDE) we don't find the class ApacheHttpClient. Only after We have added
to the project the class is available on the classpath.
We have created to projects which reproduces the behaviour. The current state is reflecting the state that the compression is configured but the auto configuration is not triggered. We have prefixed the comments of the relevant parts with a FIXME (if you want to search for them). If you change/enhance the projects the way we commented you can reproduce the service discovery bug.
The text was updated successfully, but these errors were encountered: