Add validation when constructing Http2FrameLogger (#10495)

Motivation:

There should be a validation for the input arguments when constructing Http2FrameLogger

Modification:

Check that the provided arguments are not null

Result:

Proper validation when constructing Http2FrameLogger
This commit is contained in:
Violeta Georgieva 2020-08-21 15:26:08 +03:00 committed by Norman Maurer
parent 9ab75505f8
commit a399175b52

View File

@ -42,20 +42,24 @@ public class Http2FrameLogger {
private final InternalLogLevel level; private final InternalLogLevel level;
public Http2FrameLogger(LogLevel level) { public Http2FrameLogger(LogLevel level) {
this(level.toInternalLevel(), InternalLoggerFactory.getInstance(Http2FrameLogger.class)); this(checkAndConvertLevel(level), InternalLoggerFactory.getInstance(Http2FrameLogger.class));
} }
public Http2FrameLogger(LogLevel level, String name) { public Http2FrameLogger(LogLevel level, String name) {
this(level.toInternalLevel(), InternalLoggerFactory.getInstance(name)); this(checkAndConvertLevel(level), InternalLoggerFactory.getInstance(requireNonNull(name, "name")));
} }
public Http2FrameLogger(LogLevel level, Class<?> clazz) { public Http2FrameLogger(LogLevel level, Class<?> clazz) {
this(level.toInternalLevel(), InternalLoggerFactory.getInstance(clazz)); this(checkAndConvertLevel(level), InternalLoggerFactory.getInstance(requireNonNull(clazz, "clazz")));
} }
private Http2FrameLogger(InternalLogLevel level, InternalLogger logger) { private Http2FrameLogger(InternalLogLevel level, InternalLogger logger) {
this.level = requireNonNull(level, "level"); this.level = level;
this.logger = requireNonNull(logger, "logger"); this.logger = logger;
}
private static InternalLogLevel checkAndConvertLevel(LogLevel level) {
return requireNonNull(level, "level").toInternalLevel();
} }
public boolean isEnabled() { public boolean isEnabled() {