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 GitHub
parent b2e52e98a3
commit 4be9387151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,20 +43,24 @@ public class Http2FrameLogger extends ChannelHandlerAdapter {
private final InternalLogLevel 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) {
this(level.toInternalLevel(), InternalLoggerFactory.getInstance(name));
this(checkAndConvertLevel(level), InternalLoggerFactory.getInstance(checkNotNull(name, "name")));
}
public Http2FrameLogger(LogLevel level, Class<?> clazz) {
this(level.toInternalLevel(), InternalLoggerFactory.getInstance(clazz));
this(checkAndConvertLevel(level), InternalLoggerFactory.getInstance(checkNotNull(clazz, "clazz")));
}
private Http2FrameLogger(InternalLogLevel level, InternalLogger logger) {
this.level = checkNotNull(level, "level");
this.logger = checkNotNull(logger, "logger");
this.level = level;
this.logger = logger;
}
private static InternalLogLevel checkAndConvertLevel(LogLevel level) {
return checkNotNull(level, "level").toInternalLevel();
}
public boolean isEnabled() {