Polishing contribution
Closes gh-30403
This commit is contained in:
@@ -123,15 +123,13 @@ final class HttpServiceMethod {
|
||||
}
|
||||
}
|
||||
int index = i;
|
||||
Assert.state(resolved, () -> formatArgumentError(this.parameters[index], "No suitable resolver"));
|
||||
Assert.state(resolved, () ->
|
||||
"Could not resolve parameter [" + this.parameters[index].getParameterIndex() + "] in " +
|
||||
this.parameters[index].getExecutable().toGenericString() +
|
||||
(StringUtils.hasText("No suitable resolver") ? ": " + "No suitable resolver" : ""));
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatArgumentError(MethodParameter param, String message) {
|
||||
return "Could not resolve parameter [" + param.getParameterIndex() + "] in " +
|
||||
param.getExecutable().toGenericString() + (StringUtils.hasText(message) ? ": " + message : "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Factory for {@link HttpRequestValues} with values extracted from the type
|
||||
@@ -277,17 +275,6 @@ final class HttpServiceMethod {
|
||||
@Nullable ReactiveAdapter returnTypeAdapter,
|
||||
boolean blockForOptional, @Nullable Duration blockTimeout) {
|
||||
|
||||
private ResponseFunction(
|
||||
Function<HttpRequestValues, Publisher<?>> responseFunction,
|
||||
@Nullable ReactiveAdapter returnTypeAdapter,
|
||||
boolean blockForOptional, Duration blockTimeout) {
|
||||
|
||||
this.responseFunction = responseFunction;
|
||||
this.returnTypeAdapter = returnTypeAdapter;
|
||||
this.blockForOptional = blockForOptional;
|
||||
this.blockTimeout = blockTimeout;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object execute(HttpRequestValues requestValues) {
|
||||
|
||||
@@ -297,11 +284,16 @@ final class HttpServiceMethod {
|
||||
return this.returnTypeAdapter.fromPublisher(responsePublisher);
|
||||
}
|
||||
|
||||
return (this.blockForOptional ?
|
||||
(this.blockTimeout != null ? ((Mono<?>) responsePublisher).blockOptional(this.blockTimeout) :
|
||||
((Mono<?>) responsePublisher).blockOptional()) :
|
||||
(this.blockTimeout != null ? ((Mono<?>) responsePublisher).block(this.blockTimeout) :
|
||||
((Mono<?>) responsePublisher).block()));
|
||||
if (this.blockForOptional) {
|
||||
return (this.blockTimeout != null ?
|
||||
((Mono<?>) responsePublisher).blockOptional(this.blockTimeout) :
|
||||
((Mono<?>) responsePublisher).blockOptional());
|
||||
}
|
||||
else {
|
||||
return (this.blockTimeout != null ?
|
||||
((Mono<?>) responsePublisher).block(this.blockTimeout) :
|
||||
((Mono<?>) responsePublisher).block());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -310,7 +302,7 @@ final class HttpServiceMethod {
|
||||
*/
|
||||
public static ResponseFunction create(
|
||||
HttpClientAdapter client, Method method, ReactiveAdapterRegistry reactiveRegistry,
|
||||
Duration blockTimeout) {
|
||||
@Nullable Duration blockTimeout) {
|
||||
|
||||
MethodParameter returnParam = new MethodParameter(method, -1);
|
||||
Class<?> returnType = returnParam.getParameterType();
|
||||
|
||||
@@ -207,14 +207,16 @@ public final class HttpServiceProxyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure how long to wait for a response for an HTTP service method
|
||||
* Configure how long to block for the response of an HTTP service method
|
||||
* with a synchronous (blocking) method signature.
|
||||
* <p>By default this is {@code null},
|
||||
* in which case means blocking on publishers is done without a timeout.
|
||||
* <p>By default this is not set, in which case the behavior depends on
|
||||
* connection and request timeout settings of the underlying HTTP client.
|
||||
* We recommend configuring timeout values directly on the underlying HTTP
|
||||
* client, which provides more control over such settings.
|
||||
* @param blockTimeout the timeout value
|
||||
* @return this same builder instance
|
||||
*/
|
||||
public Builder blockTimeout(Duration blockTimeout) {
|
||||
public Builder blockTimeout(@Nullable Duration blockTimeout) {
|
||||
this.blockTimeout = blockTimeout;
|
||||
return this;
|
||||
}
|
||||
@@ -227,8 +229,7 @@ public final class HttpServiceProxyFactory {
|
||||
|
||||
return new HttpServiceProxyFactory(
|
||||
this.clientAdapter, initArgumentResolvers(),
|
||||
this.embeddedValueResolver, this.reactiveAdapterRegistry,
|
||||
this.blockTimeout);
|
||||
this.embeddedValueResolver, this.reactiveAdapterRegistry, this.blockTimeout);
|
||||
}
|
||||
|
||||
private List<HttpServiceArgumentResolver> initArgumentResolvers() {
|
||||
|
||||
Reference in New Issue
Block a user