mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge pull request #51509 from kdomo
Closes gh-51509 * fix-http-client-assert: Polish "Fix null customizer checks in HTTP client builders" Fix null customizer checks in HTTP client builders
This commit is contained in:
+1
-1
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -54,6 +54,7 @@ import org.springframework.util.StreamUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Base class for {@link ClientHttpRequestFactoryBuilder} tests.
|
||||
@@ -76,6 +77,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();
|
||||
|
||||
+8
@@ -56,6 +56,7 @@ import org.springframework.web.reactive.function.client.WebClientRequestExceptio
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Base class for {@link ClientHttpConnectorBuilder} tests.
|
||||
@@ -77,6 +78,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();
|
||||
|
||||
Reference in New Issue
Block a user