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)
- Warn in the documentation that spring.profiles.group can only be used in non-profile-specific documents
- Fix various minor inconsistencies of the documentation
- Add Kotlin example for @Testcontainers
- Add platform option for image building
- Application fails to start when server.tomcat.threads.max < 10 HOT 3
- CDS extract fails if application has its own META-INF directory HOT 3
- org.springframework.boot/spring-boot-starter-test Does not work with a module path HOT 1
- MessagingAnnotationBeanPostProcessor or ProxyTransactionManagementConfiguration BeanPostProcessor error HOT 6
- upgrade 3.2.6 corrupts published parent pom artifact HOT 5
- In 3.2.3+ , the auto-configured reactiveNeo4jTransactionManager may caused a failure due to multiple TransactionManager beans
- Gradle Plugin "Getting Started" documentation section out of date HOT 3
- Multiple values in X-Forwarded-Host not supported by NATIVE forward headers strategy HOT 1
- The value of the tomcat.threads.config.max metric is always -1, irrespective of the configured maximum number of threads HOT 3
- Fix typo in Dev Services reference docs
- Remove unused parameter and polish javadoc
- /livez and /readyz are shut down when Spring Security is on the classpath and CloudPlatform is CLOUD_FOUNDRY HOT 1
- Autoconfigure and QueryDSL HOT 3
- spring dynamic bean annotation not invoked HOT 1
- Update commons-compress from 1.25.0 to 1.26.2 HOT 1
- Lombok Unexpected Deletion Issue in **Spring Boot Project v3.2.5** HOT 2
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.