Remove attributes from RestClient
This commit removes any references to attributes from RestClient, which were left by mistake. Closes gh-31625
This commit is contained in:
parent
8567402969
commit
e6ab8a6d61
|
@ -26,7 +26,6 @@ import java.nio.charset.Charset;
|
|||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -83,8 +82,6 @@ final class DefaultRestClient implements RestClient {
|
|||
|
||||
private static final ClientRequestObservationConvention DEFAULT_OBSERVATION_CONVENTION = new DefaultClientRequestObservationConvention();
|
||||
|
||||
private static final String URI_TEMPLATE_ATTRIBUTE = RestClient.class.getName() + ".uriTemplate";
|
||||
|
||||
|
||||
private final ClientHttpRequestFactory clientRequestFactory;
|
||||
|
||||
|
@ -256,7 +253,8 @@ final class DefaultRestClient implements RestClient {
|
|||
@Nullable
|
||||
private InternalBody body;
|
||||
|
||||
private final Map<String, Object> attributes = new LinkedHashMap<>(4);
|
||||
@Nullable
|
||||
private String uriTemplate;
|
||||
|
||||
@Nullable
|
||||
private Consumer<ClientHttpRequest> httpRequestConsumer;
|
||||
|
@ -267,19 +265,19 @@ final class DefaultRestClient implements RestClient {
|
|||
|
||||
@Override
|
||||
public RequestBodySpec uri(String uriTemplate, Object... uriVariables) {
|
||||
attribute(URI_TEMPLATE_ATTRIBUTE, uriTemplate);
|
||||
this.uriTemplate = uriTemplate;
|
||||
return uri(DefaultRestClient.this.uriBuilderFactory.expand(uriTemplate, uriVariables));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestBodySpec uri(String uriTemplate, Map<String, ?> uriVariables) {
|
||||
attribute(URI_TEMPLATE_ATTRIBUTE, uriTemplate);
|
||||
this.uriTemplate = uriTemplate;
|
||||
return uri(DefaultRestClient.this.uriBuilderFactory.expand(uriTemplate, uriVariables));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestBodySpec uri(String uriTemplate, Function<UriBuilder, URI> uriFunction) {
|
||||
attribute(URI_TEMPLATE_ATTRIBUTE, uriTemplate);
|
||||
this.uriTemplate = uriTemplate;
|
||||
return uri(uriFunction.apply(DefaultRestClient.this.uriBuilderFactory.uriString(uriTemplate)));
|
||||
}
|
||||
|
||||
|
@ -351,18 +349,6 @@ final class DefaultRestClient implements RestClient {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestBodySpec attribute(String name, Object value) {
|
||||
this.attributes.put(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestBodySpec attributes(Consumer<Map<String, Object>> attributesConsumer) {
|
||||
attributesConsumer.accept(this.attributes);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestBodySpec httpRequest(Consumer<ClientHttpRequest> requestConsumer) {
|
||||
this.httpRequestConsumer = (this.httpRequestConsumer != null ?
|
||||
|
@ -455,7 +441,7 @@ final class DefaultRestClient implements RestClient {
|
|||
ClientHttpRequest clientRequest = createRequest(uri);
|
||||
clientRequest.getHeaders().addAll(headers);
|
||||
ClientRequestObservationContext observationContext = new ClientRequestObservationContext(clientRequest);
|
||||
observationContext.setUriTemplate((String) this.attributes.get(URI_TEMPLATE_ATTRIBUTE));
|
||||
observationContext.setUriTemplate(this.uriTemplate);
|
||||
observation = ClientHttpObservationDocumentation.HTTP_CLIENT_EXCHANGES.observation(observationConvention,
|
||||
DEFAULT_OBSERVATION_CONVENTION, () -> observationContext, observationRegistry).start();
|
||||
if (this.body != null) {
|
||||
|
|
|
@ -498,22 +498,6 @@ public interface RestClient {
|
|||
*/
|
||||
S headers(Consumer<HttpHeaders> headersConsumer);
|
||||
|
||||
/**
|
||||
* Set the attribute with the given name to the given value.
|
||||
* @param name the name of the attribute to add
|
||||
* @param value the value of the attribute to add
|
||||
* @return this builder
|
||||
*/
|
||||
S attribute(String name, Object value);
|
||||
|
||||
/**
|
||||
* Provides access to every attribute declared so far with the
|
||||
* possibility to add, replace, or remove values.
|
||||
* @param attributesConsumer the consumer to provide access to
|
||||
* @return this builder
|
||||
*/
|
||||
S attributes(Consumer<Map<String, Object>> attributesConsumer);
|
||||
|
||||
/**
|
||||
* Callback for access to the {@link ClientHttpRequest} that in turn
|
||||
* provides access to the native request of the underlying HTTP library.
|
||||
|
|
|
@ -119,8 +119,6 @@ public final class RestClientAdapter implements HttpExchangeAdapter {
|
|||
bodySpec.header(HttpHeaders.COOKIE, String.join("; ", cookies));
|
||||
}
|
||||
|
||||
bodySpec.attributes(attributes -> attributes.putAll(values.getAttributes()));
|
||||
|
||||
if (values.getBodyValue() != null) {
|
||||
bodySpec.body(values.getBodyValue());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue