Skip to content

Commit

Permalink
Removed unused methods
Browse files Browse the repository at this point in the history
Related to PR #2203
  • Loading branch information
violetagg committed May 18, 2022
1 parent ee7bd56 commit 9500b8a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.time.Duration;
import java.util.Objects;
import java.util.function.BiConsumer;
Expand All @@ -43,7 +42,6 @@
import io.netty.handler.ssl.SslClosedEngineException;
import io.netty.resolver.AddressResolverGroup;
import io.netty.util.AsciiString;
import io.netty.util.AttributeKey;
import io.netty.util.NetUtil;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscription;
Expand All @@ -58,7 +56,6 @@
import reactor.netty.http.HttpOperations;
import reactor.netty.http.HttpProtocol;
import reactor.netty.resources.ConnectionProvider;
import reactor.netty.tcp.TcpClientConfig;
import reactor.netty.transport.AddressUtils;
import reactor.netty.transport.ProxyProvider;
import reactor.netty.tcp.SslProvider;
Expand Down Expand Up @@ -140,61 +137,6 @@ protected HttpClient duplicate() {
return new HttpClientConnect(new HttpClientConfig(config));
}

@SuppressWarnings("unchecked")
static HttpClient applyTcpClientConfig(TcpClientConfig config) {
HttpClient httpClient =
create(config.connectionProvider()).doOnChannelInit(config.doOnChannelInit())
.observe(config.connectionObserver())
.remoteAddress(config.remoteAddress())
.runOn(config.loopResources(), config.isPreferNative());

if (config.resolver() != null) {
httpClient = httpClient.resolver(config.resolver());
}

for (Map.Entry<AttributeKey<?>, ?> entry : config.attributes().entrySet()) {
httpClient = httpClient.attr((AttributeKey<Object>) entry.getKey(), entry.getValue());
}

if (config.bindAddress() != null) {
httpClient = httpClient.bindAddress(config.bindAddress());
}

if (config.channelGroup() != null) {
httpClient = httpClient.channelGroup(config.channelGroup());
}

if (config.doOnConnected() != null) {
httpClient = httpClient.doOnConnected(config.doOnConnected());
}

if (config.doOnDisconnected() != null) {
httpClient = httpClient.doOnDisconnected(config.doOnDisconnected());
}

if (config.loggingHandler() != null) {
httpClient.configuration().loggingHandler(config.loggingHandler());
}

if (config.metricsRecorder() != null) {
httpClient = httpClient.metrics(true, config.metricsRecorder());
}

for (Map.Entry<ChannelOption<?>, ?> entry : config.options().entrySet()) {
httpClient = httpClient.option((ChannelOption<Object>) entry.getKey(), entry.getValue());
}

if (config.proxyProvider() != null) {
httpClient.configuration().proxyProvider(config.proxyProvider());
}

if (config.sslProvider() != null) {
httpClient = httpClient.secure(config.sslProvider());
}

return httpClient;
}

static final class MonoHttpConnect extends Mono<Connection> {

final HttpClientConfig config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2021 VMware, Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2017-2022 VMware, Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,11 +16,9 @@
package reactor.netty.http.server;

import io.netty.channel.ChannelOption;
import io.netty.util.AttributeKey;
import reactor.core.publisher.Mono;
import reactor.netty.DisposableServer;
import reactor.netty.tcp.SslProvider;
import reactor.netty.tcp.TcpServerConfig;

import java.net.InetSocketAddress;
import java.util.Arrays;
Expand Down Expand Up @@ -107,64 +105,5 @@ protected HttpServer duplicate() {
return new HttpServerBind(new HttpServerConfig(config));
}

@SuppressWarnings("unchecked")
static HttpServer applyTcpServerConfig(TcpServerConfig config) {
HttpServer httpServer =
create().childObserve(config.childObserver())
.doOnChannelInit(config.doOnChannelInit())
.observe(config.connectionObserver())
.runOn(config.loopResources(), config.isPreferNative());

for (Map.Entry<AttributeKey<?>, ?> entry : config.attributes().entrySet()) {
httpServer = httpServer.attr((AttributeKey<Object>) entry.getKey(), entry.getValue());
}

if (config.bindAddress() != null) {
httpServer = httpServer.bindAddress(config.bindAddress());
}

if (config.channelGroup() != null) {
httpServer = httpServer.channelGroup(config.channelGroup());
}

for (Map.Entry<AttributeKey<?>, ?> entry : config.childAttributes().entrySet()) {
httpServer = httpServer.childAttr((AttributeKey<Object>) entry.getKey(), entry.getValue());
}

for (Map.Entry<ChannelOption<?>, ?> entry : config.childOptions().entrySet()) {
httpServer = httpServer.childOption((ChannelOption<Object>) entry.getKey(), entry.getValue());
}

if (config.doOnBound() != null) {
httpServer = httpServer.doOnBound(config.doOnBound());
}

if (config.doOnConnection() != null) {
httpServer = httpServer.doOnConnection(config.doOnConnection());
}

if (config.doOnUnbound() != null) {
httpServer = httpServer.doOnUnbound(config.doOnUnbound());
}

if (config.loggingHandler() != null) {
httpServer.configuration().loggingHandler(config.loggingHandler());
}

if (config.metricsRecorder() != null) {
httpServer = httpServer.metrics(true, config.metricsRecorder());
}

for (Map.Entry<ChannelOption<?>, ?> entry : config.options().entrySet()) {
httpServer = httpServer.option((ChannelOption<Object>) entry.getKey(), entry.getValue());
}

if (config.sslProvider() != null) {
httpServer.secure(config.sslProvider());
}

return httpServer;
}

static final int DEFAULT_PORT = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
import reactor.netty.resources.ConnectionProvider;
import reactor.netty.resources.LoopResources;
import reactor.netty.tcp.SslProvider;
import reactor.netty.tcp.TcpClient;
import reactor.netty.tcp.TcpServer;
import reactor.test.StepVerifier;
import reactor.util.Logger;
Expand Down Expand Up @@ -2373,15 +2372,6 @@ void testHttpClientWithDomainSocketsWithPort() {
.block(Duration.ofSeconds(30)));
}

@Test
void testApplyTcpClientSSLConfig() throws Exception {
SslContext sslContext = SslContextBuilder.forClient().build();
TcpClient tcpClient = TcpClient.create().secure(sslProviderBuilder -> sslProviderBuilder.sslContext(sslContext));
HttpClient httpClient = HttpClientConnect.applyTcpClientConfig(tcpClient.configuration());

assertThat(tcpClient.configuration().sslProvider()).isEqualTo(httpClient.configuration().sslProvider());
}

@Test
void testUriNotAbsolute_1() {
assertThatExceptionOfType(IllegalArgumentException.class)
Expand Down

0 comments on commit 9500b8a

Please sign in to comment.