Skip to content

Commit

Permalink
Remove the ChannelProviderAdditionalOperations that does not seem nec…
Browse files Browse the repository at this point in the history
…essary
  • Loading branch information
vietj committed May 25, 2016
1 parent 8d12216 commit b7dfbfb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 57 deletions.
19 changes: 1 addition & 18 deletions src/main/java/io/vertx/core/http/impl/ConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import io.vertx.core.logging.LoggerFactory;
import io.vertx.core.net.ProxyOptions;
import io.vertx.core.net.impl.AsyncResolveBindConnectHelper;
import io.vertx.core.net.impl.ChannelProviderAdditionalOperations;
import io.vertx.core.net.impl.PartialPooledByteBufAllocator;
import io.vertx.core.net.impl.SSLHelper;
import io.vertx.core.net.impl.proxy.ProxyChannelProvider;
Expand Down Expand Up @@ -376,22 +375,6 @@ protected void internalConnect(ConnQueue queue, HttpVersion version, String host
bootstrap.channel(NioSocketChannel.class);
applyConnectionOptions(options, bootstrap);

ChannelProviderAdditionalOperations addl = new ChannelProviderAdditionalOperations() {

HttpClientCodec codec = new HttpClientCodec(4096, 8192, options.getMaxChunkSize(), false, false);

@Override
public void pipelineSetup(ChannelPipeline pipeline) {
pipeline.addLast("codec", codec);
}

@Override
public void pipelineDeprov(ChannelPipeline pipeline) {
pipeline.remove(codec);
}

};

ChannelProvider channelProvider;
if (options.getProxyOptions() == null) {
channelProvider = new ChannelProvider() {
Expand All @@ -413,7 +396,7 @@ protected void initChannel(Channel ch) throws Exception {
}
};
} else {
channelProvider = new ProxyChannelProvider(addl);
channelProvider = new ProxyChannelProvider();
}

Handler<AsyncResult<Channel>> channelHandler = res -> {
Expand Down

This file was deleted.

13 changes: 1 addition & 12 deletions src/main/java/io/vertx/core/net/impl/NetClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,6 @@ private void connect(int port, String host, Handler<AsyncResult<NetSocket>> conn
bootstrap.group(context.nettyEventLoop());
bootstrap.channel(NioSocketChannel.class);

ChannelProviderAdditionalOperations addl = new ChannelProviderAdditionalOperations() {

@Override
public void pipelineSetup(ChannelPipeline pipeline) {
}

@Override
public void pipelineDeprov(ChannelPipeline pipeline) {
}
};

bootstrap.handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) throws Exception {
Expand All @@ -198,7 +187,7 @@ public void connect(VertxInternal vertx, Bootstrap bootstrap, ProxyOptions optio
}
};
} else {
channelProvider = new ProxyChannelProvider(addl);
channelProvider = new ProxyChannelProvider();
}

Handler<AsyncResult<Channel>> channelHandler = res -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@
import io.vertx.core.net.ProxyOptions;
import io.vertx.core.net.ProxyType;
import io.vertx.core.net.impl.ChannelProvider;
import io.vertx.core.net.impl.ChannelProviderAdditionalOperations;

/**
* @author <a href="http://oss.lehmann.cx/">Alexander Lehmann</a>
*
*/
public class ProxyChannelProvider implements ChannelProvider {

private static final Logger log = LoggerFactory.getLogger(ProxyChannelProvider.class);
// Could become a singleton as it does not hold state

private final ChannelProviderAdditionalOperations addl;
private static final Logger log = LoggerFactory.getLogger(ProxyChannelProvider.class);

public ProxyChannelProvider(ChannelProviderAdditionalOperations addl) {
this.addl = addl;
public ProxyChannelProvider() {
}

@Override
Expand Down Expand Up @@ -88,14 +86,11 @@ public void connect(VertxInternal vertx, Bootstrap bootstrap, ProxyOptions optio
protected void initChannel(Channel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addFirst("proxy", proxy);
// set up other pipeline entries
addl.pipelineSetup(ch.pipeline());
pipeline.addLast(new ChannelInboundHandlerAdapter() {
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof ProxyConnectionEvent) {
pipeline.remove(proxy);
addl.pipelineDeprov(pipeline);
pipeline.remove(this);
channelHandler.handle(Future.succeededFuture(ch));
}
Expand Down

0 comments on commit b7dfbfb

Please sign in to comment.