Merge branch '4.0.x' into 4.1.x

Closes gh-51513
This commit is contained in:
Stéphane Nicoll
2026-08-30 20:27:47 +02:00
6 changed files with 20 additions and 2 deletions
@@ -48,7 +48,7 @@ abstract class AbstractClientHttpRequestFactoryBuilder<T extends ClientHttpReque
}
protected final List<Consumer<T>> mergedCustomizers(Consumer<T> customizer) {
Assert.notNull(this.customizers, "'customizer' must not be null");
Assert.notNull(customizer, "'customizer' must not be null");
return merge(this.customizers, List.of(customizer));
}
@@ -70,6 +70,7 @@ public interface ClientHttpRequestFactoryBuilder<T extends ClientHttpRequestFact
* @return a new {@link ClientHttpRequestFactoryBuilder} instance
*/
default ClientHttpRequestFactoryBuilder<T> withCustomizer(Consumer<T> customizer) {
Assert.notNull(customizer, "'customizer' must not be null");
return withCustomizers(List.of(customizer));
}
@@ -49,7 +49,7 @@ abstract class AbstractClientHttpConnectorBuilder<T extends ClientHttpConnector>
}
protected final List<Consumer<T>> mergedCustomizers(Consumer<T> customizer) {
Assert.notNull(this.customizers, "'customizer' must not be null");
Assert.notNull(customizer, "'customizer' must not be null");
return merge(this.customizers, List.of(customizer));
}
@@ -68,6 +68,7 @@ public interface ClientHttpConnectorBuilder<T extends ClientHttpConnector> {
* @return a new {@link ClientHttpConnectorBuilder} instance
*/
default ClientHttpConnectorBuilder<T> withCustomizer(Consumer<T> customizer) {
Assert.notNull(customizer, "'customizer' must not be null");
return withCustomizers(List.of(customizer));
}
@@ -55,6 +55,7 @@ import org.springframework.util.StreamUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Base class for {@link ClientHttpRequestFactoryBuilder} tests.
@@ -77,6 +78,13 @@ abstract class AbstractClientHttpRequestFactoryBuilderTests<T extends ClientHttp
this.builder = builder;
}
@Test
@SuppressWarnings("NullAway") // Test null check
void withCustomizerWhenCustomizerIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.builder.withCustomizer(null))
.withMessage("'customizer' must not be null");
}
@Test
void buildReturnsRequestFactoryOfExpectedType() {
T requestFactory = this.builder.build();
@@ -59,6 +59,7 @@ import org.springframework.web.reactive.function.client.WebClientRequestExceptio
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Base class for {@link ClientHttpConnectorBuilder} tests.
@@ -80,6 +81,13 @@ abstract class AbstractClientHttpConnectorBuilderTests<T extends ClientHttpConne
this.builder = builder;
}
@Test
@SuppressWarnings("NullAway") // Test null check
void withCustomizerWhenCustomizerIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.builder.withCustomizer(null))
.withMessage("'customizer' must not be null");
}
@Test
void buildReturnsConnectorOfExpectedType() {
T connector = this.builder.build();