Skip to content

Commit

Permalink
Remove nullable from DefaultSingleAddressHttpClientBuilder.address (#…
Browse files Browse the repository at this point in the history
…2999)

Motivation:

Looks like a historical leftover. In the current state, `address` can
not be `null`.

Modifications:

- Remove `@Nullable` annotation from
`DefaultSingleAddressHttpClientBuilder.address`;
- Remove unnecessary assertions;

Result:

Less null noise.
  • Loading branch information
idelpivnitskiy authored Jul 10, 2024
1 parent 72e9511 commit 3fb51b5
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ final class DefaultSingleAddressHttpClientBuilder<U, R> implements SingleAddress
static final Duration SD_RETRY_STRATEGY_INIT_DURATION = ofSeconds(2);
static final Duration SD_RETRY_STRATEGY_MAX_DELAY = ofSeconds(128);

@Nullable
private final U address;
@Nullable
private U proxyAddress;
Expand Down Expand Up @@ -148,9 +147,9 @@ final class DefaultSingleAddressHttpClientBuilder<U, R> implements SingleAddress
clientFilterFactory = appendFilter(clientFilterFactory, HttpMessageDiscardWatchdogClientFilter.CLIENT_CLEANER);
}

private DefaultSingleAddressHttpClientBuilder(@Nullable final U address,
private DefaultSingleAddressHttpClientBuilder(final U address,
final DefaultSingleAddressHttpClientBuilder<U, R> from) {
this.address = address;
this.address = requireNonNull(address);
proxyAddress = from.proxyAddress;
config = new HttpClientConfig(from.config);
executionContextBuilder = new HttpExecutionContextBuilder(from.executionContextBuilder);
Expand Down Expand Up @@ -194,7 +193,6 @@ private static final class HttpClientBuildContext<U, R> {
}

U address() {
assert builder.address != null : "Attempted to buildStreaming with an unknown address";
return builder.proxyAddress != null ? builder.proxyAddress : builder.address;
}

Expand Down Expand Up @@ -450,7 +448,6 @@ private HttpClientBuildContext<U, R> copyBuildCtx() {
}

private AbsoluteAddressHttpRequesterFilter proxyAbsoluteAddressFilterFactory() {
assert address != null : "address should have been set in constructor";
return new AbsoluteAddressHttpRequesterFilter("http", hostToCharSequenceFunction.apply(address));
}

Expand Down Expand Up @@ -625,7 +622,6 @@ public DefaultSingleAddressHttpClientBuilder<U, R> loadBalancerFactory(

@Override
public DefaultSingleAddressHttpClientBuilder<U, R> sslConfig(ClientSslConfig sslConfig) {
assert address != null;
// defer setting the fallback host/port so the user has a chance to configure hostToCharSequenceFunction.
setFallbackHostAndPort(config, address);
config.tcpConfig().sslConfig(sslConfig);
Expand Down

0 comments on commit 3fb51b5

Please sign in to comment.