Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for OpenSslEngine with no finalizer #1669

Merged
merged 1 commit into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ public interface SslEngineFactory {
default void init(AsyncHttpClientConfig config) throws SSLException {
// no op
}

/**
* Perform any necessary cleanup.
*/
default void destroy() {
// no op
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.netty.channel.*;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.group.ChannelGroup;
import io.netty.channel.group.ChannelGroupFuture;
import io.netty.channel.group.DefaultChannelGroup;
import io.netty.channel.kqueue.KQueueEventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
Expand Down Expand Up @@ -287,8 +288,9 @@ public void removeAll(Channel connection) {
}

private void doClose() {
openChannels.close();
ChannelGroupFuture groupFuture = openChannels.close();
channelPool.destroy();
groupFuture.addListener(future -> sslEngineFactory.destroy());
}

public void close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.SslProvider;
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import io.netty.util.ReferenceCountUtil;
import org.asynchttpclient.AsyncHttpClientConfig;

import javax.net.ssl.SSLEngine;
Expand Down Expand Up @@ -73,6 +74,11 @@ public void init(AsyncHttpClientConfig config) throws SSLException {
sslContext = buildSslContext(config);
}

@Override
public void destroy() {
ReferenceCountUtil.release(sslContext);
}

/**
* The last step of configuring the SslContextBuilder used to create an SslContext when no context is provided in the {@link AsyncHttpClientConfig}. This defaults to no-op and
* is intended to be overridden as needed.
Expand Down