Skip to content

Commit

Permalink
Force netty server to use java.util.logging
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jan 16, 2020
1 parent 9c24b1e commit b4bbfd3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions java/maven_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def selenium_java_deps():
"io.netty:netty-buffer:%s" % netty_version,
"io.netty:netty-codec-haproxy:%s" % netty_version,
"io.netty:netty-codec-http:%s" % netty_version,
"io.netty:netty-common:%s" % netty_version,
"io.netty:netty-handler:%s" % netty_version,
"io.netty:netty-transport:%s" % netty_version,
"io.opentracing:opentracing-api:0.33.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ java_library(
artifact("com.google.guava:guava"),
artifact("io.netty:netty-buffer"),
artifact("io.netty:netty-codec-http"),
artifact("io.netty:netty-common"),
artifact("io.netty:netty-handler"),
artifact("io.netty:netty-transport"),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
Expand All @@ -28,16 +27,18 @@
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.util.SelfSignedCertificate;
import io.netty.util.internal.logging.InternalLoggerFactory;
import io.netty.util.internal.logging.JdkLoggerFactory;
import org.openqa.selenium.grid.server.AddWebDriverSpecHeaders;
import org.openqa.selenium.grid.server.BaseServerOptions;
import org.openqa.selenium.grid.server.Server;
import org.openqa.selenium.grid.server.WrapExceptions;
import org.openqa.selenium.remote.http.HttpHandler;

import javax.net.ssl.SSLException;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import javax.net.ssl.SSLException;
import java.net.URL;
import java.security.cert.CertificateException;
import java.util.Objects;
Expand All @@ -57,13 +58,15 @@ public NettyServer(BaseServerOptions options, HttpHandler handler) {
Objects.requireNonNull(options, "Server options must be set.");
Objects.requireNonNull(handler, "Handler to use must be set.");

Boolean secure = options.isSecure();
InternalLoggerFactory.setDefaultFactory(JdkLoggerFactory.getDefaultFactory());

boolean secure = options.isSecure();
if (secure) {
try {
sslCtx = SslContextBuilder.forServer(options.getCertificate(), options.getPrivateKey())
.build();
} catch (SSLException e) {
throw new UncheckedIOException(new IOException("Certificate problem.", e));
throw new UncheckedIOException(new IOException("Certificate problem.", e));
}
} else if (options.isSelfSigned()) {
try {
Expand Down Expand Up @@ -120,7 +123,7 @@ public NettyServer start() {

b.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.handler(new LoggingHandler(LogLevel.INFO))
.handler(new LoggingHandler(LogLevel.DEBUG))
.childHandler(new SeleniumHttpInitializer(handler, sslCtx));

try {
Expand Down

0 comments on commit b4bbfd3

Please sign in to comment.