Comments (5)
None of Spring Boot's built-in request factory implementations (HttpComponentsClientHttpRequestFactory
, JettyClientHttpRequestFactory
, JdkClientHttpRequestFactory
, SimpleClientHttpRequestFactory
, OkHttp3ClientHttpRequestFactory
) use this Reflective
class for setting properties. When Jetty is being used for the client connection, the read timeout is set here using the Jetty setReadTimeout
method that takes a long
:
If you are somehow jave a ClientHttpRequestFactory
implementation with Jetty that goes through the Reflective
code path, can you show us an example of what you're doing?
from spring-boot.
Yes, I do have such a path. We create a RestTemplate using the RestTemplateBuilder. We'd like every request sent by the template to be wrapped by a BufferingRequest (in order to be able to log the request before it's sent), but the nested request should be created as configured by other factories. Hence we use this:
restTemplateBuilder
.requestFactory(() ->
new BufferingClientHttpRequestFactory(ClientHttpRequestFactories.get(ClientHttpRequestFactorySettings.DEFAULTS)))
This form of the "requestFactory" method uses Reflective
.
from spring-boot.
Reproducer here: sb-40635.zip
Works with Boot 3.1.x, fails with 3.2.x and 3.3.x:
java.lang.IllegalStateException: Request factory org.springframework.http.client.JettyClientHttpRequestFactory does not have a suitable setReadTimeout method
at org.springframework.util.Assert.state(Assert.java:97) ~[spring-core-6.1.6.jar:6.1.6]
at org.springframework.boot.web.client.ClientHttpRequestFactories$Reflective.findMethod(ClientHttpRequestFactories.java:402) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.web.client.ClientHttpRequestFactories$Reflective.setReadTimeout(ClientHttpRequestFactories.java:394) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.web.client.ClientHttpRequestFactories$Reflective.lambda$configure$1(ClientHttpRequestFactories.java:369) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.context.properties.PropertyMapper$Source.to(PropertyMapper.java:294) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.web.client.ClientHttpRequestFactories$Reflective.configure(ClientHttpRequestFactories.java:369) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.web.client.ClientHttpRequestFactories$Reflective.get(ClientHttpRequestFactories.java:360) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.web.client.ClientHttpRequestFactories.get(ClientHttpRequestFactories.java:168) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.web.client.RestTemplateBuilder.lambda$requestFactory$1(RestTemplateBuilder.java:320) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.web.client.RestTemplateBuilder.buildRequestFactory(RestTemplateBuilder.java:659) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.web.client.RestTemplateBuilder.configure(RestTemplateBuilder.java:625) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.web.client.RestTemplateBuilder.build(RestTemplateBuilder.java:600) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.example.sb40635.CLR.run(CLR.java:31) ~[main/:na]
at org.springframework.boot.SpringApplication.lambda$callRunner$5(SpringApplication.java:790) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.util.function.ThrowingConsumer$1.acceptWithException(ThrowingConsumer.java:83) ~[spring-core-6.1.6.jar:6.1.6]
at org.springframework.util.function.ThrowingConsumer.accept(ThrowingConsumer.java:60) ~[spring-core-6.1.6.jar:6.1.6]
at org.springframework.util.function.ThrowingConsumer$1.accept(ThrowingConsumer.java:88) ~[spring-core-6.1.6.jar:6.1.6]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:789) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.SpringApplication.lambda$callRunners$3(SpringApplication.java:774) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]
at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[na:na]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:774) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:341) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-3.3.0-RC1.jar:3.3.0-RC1]
at org.example.sb40635.Sb40635Application.main(Sb40635Application.java:10) ~[main/:na]
from spring-boot.
The ClientHttpRequestFactory
we support have the following signatures:
HttpComponentsClientHttpRequestFactory
- setConnectTimeout int
- setConnectTimeout Duration
- no setReadTimeout
JettyClientHttpRequestFactory
- setConnectTimeout int
- setConnectTimeout Duration
- setReadTimeout Duration
- setReadTimeout long
JdkClientHttpRequestFactory
- no setConnectTimeout
- setReadTimeout Duration
- setReadTimeout int
SimpleClientHttpRequestFactory
- setConnectTimeout int
- setConnectTimeout Duration
- setReadTimeout Duration
- setReadTimeout int
OkHttp3ClientHttpRequestFactory
- setConnectTimeout int
- setConnectTimeout Duration
- setReadTimeout Duration
- setReadTimeout int
We can fix this bei either preferring the Duration
accepting methods or by getting the setReadTimeout
fixed in JettyClientHttpRequestFactory
to also accept an integer.
We currently assume in the Reflective
class that the int methods accept milliseconds:
int timeout = Math.toIntExact(readTimeout.toMillis());
I think preferring the Duration
accepting methods would be the better fix.
from spring-boot.
We currently assume in the Reflective class that the int methods accept milliseconds
I'd also search for a method with a long
parameter since this type is often used for expressing periods in milliseconds.
from spring-boot.
Related Issues (20)
- Relocate test CNB builder used in plugin integration tests
- spring.config.import does not find/load nested properties-files HOT 1
- @JvmStatic missing for @DynamicPropertySource in @Testcontainers HOT 1
- Upgrade to Spring AMQP 3.0.14
- Upgrade to Spring Framework 6.0.21
- Upgrade to Spring Integration 6.1.9
- Upgrade to Spring AMQP 3.1.5
- Upgrade to Spring Framework 6.1.8
- Upgrade to Spring AMQP 3.1.5
- Upgrade to Spring Framework 6.1.8
- Fix typo in CertificateMatchingTestSource class
- Non-configurable elasticsearch client connection pool HOT 2
- Trouble Running Spring Boot Application from Jar with Included Dependencies for fast startup HOT 1
- Add missing Testcontainers service connection tests
- Add missing Testcontainers service connection tests
- Spring Boot With Postgresql Inheritance Feature not working HOT 1
- Document that a custom HttpMessageConverters bean can be used to reorder json message converters when needed
- Document that a custom HttpMessageConverters bean can be used to reorder json message converters when needed
- Upgrade to Native Build Tools Plugin 0.10.2
- Upgrade to Pulsar 3.2.3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot.