Search in sources :

Example 1 with NettyStreamFactoryFactory

use of com.mongodb.connection.netty.NettyStreamFactoryFactory in project mongo-java-driver by mongodb.

the class ClusterFixture method getOverriddenStreamFactoryFactory.

@Nullable
public static StreamFactoryFactory getOverriddenStreamFactoryFactory() {
    String streamType = System.getProperty("org.mongodb.test.async.type", "nio2");
    if (nettyStreamFactoryFactory == null && streamType.equals("netty")) {
        NettyStreamFactoryFactory.Builder builder = NettyStreamFactoryFactory.builder();
        String sslProvider = System.getProperty("org.mongodb.test.netty.ssl.provider");
        if (sslProvider != null) {
            SslContext sslContext;
            try {
                sslContext = SslContextBuilder.forClient().sslProvider(SslProvider.valueOf(sslProvider)).build();
            } catch (SSLException e) {
                throw new MongoClientException("Unable to create Netty SslContext", e);
            }
            builder.sslContext(sslContext);
        }
        nettyStreamFactoryFactory = builder.build();
    }
    return nettyStreamFactoryFactory;
}
Also used : BsonString(org.bson.BsonString) NettyStreamFactoryFactory(com.mongodb.connection.netty.NettyStreamFactoryFactory) SSLException(javax.net.ssl.SSLException) SslContext(io.netty.handler.ssl.SslContext) Nullable(com.mongodb.lang.Nullable)

Aggregations

NettyStreamFactoryFactory (com.mongodb.connection.netty.NettyStreamFactoryFactory)1 Nullable (com.mongodb.lang.Nullable)1 SslContext (io.netty.handler.ssl.SslContext)1 SSLException (javax.net.ssl.SSLException)1 BsonString (org.bson.BsonString)1