Feign: OkHttp connect and read timeouts overwritten by feign

Created on 7 Sep 2018  路  2Comments  路  Source: OpenFeign/feign

The connect and read timeout configuration in the OkHttpClient is overwritten by feign in the code below when no options are set in feign.
Is there any specific reason to do it?

https://github.com/OpenFeign/feign/blob/32372293454dbcc7797f758586e7da1617b88fd3/okhttp/src/main/java/feign/okhttp/OkHttpClient.java#L158

This is some code example where the OkHttpClient timeout configuration is ignored and the default feign values are used instead.

        OkHttpClient client = unsafeHttpClient().newBuilder()
                                                .readTimeout(130, TimeUnit.SECONDS)
                                                .writeTimeout(130, `TimeUnit.SECONDS)
                                                .build();

        return Feign.builder()
                    .errorDecoder(new EdocErrorDecoder(objectMapper()))
                    .encoder(new FormEncoder())
                    .decoder(new JacksonDecoder(objectMapper()))
                    .logger(new Slf4jLogger())
                    .client(new feign.okhttp.OkHttpClient(client))
                    .target(MyService.class, myServiceUrl);

documentation

Most helpful comment

Providing Options works but I would expect feign to honor the client settings when no options are provided.

All 2 comments

I don't recall any specific reason other than to honor any Options provided. Have you tried providing Options with your desired values instead of setting them directly on the client?

Providing Options works but I would expect feign to honor the client settings when no options are provided.

Was this page helpful?
0 / 5 - 0 ratings