-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24359 from gastaldi/log_level
Fix NPE when setting the logger level to null
- Loading branch information
Showing
2 changed files
with
55 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...http/runtime/src/test/java/io/quarkus/vertx/http/runtime/logstream/LogControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.quarkus.vertx.http.runtime.logstream; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class LogControllerTest { | ||
|
||
@Test | ||
void updateLogLevelShouldUseParentWhenLevelIsNull() { | ||
Logger logger = Logger.getLogger("foo.bar"); | ||
logger.setLevel(Level.CONFIG); | ||
Logger parent = Logger.getLogger("foo"); | ||
LogController.updateLogLevel("foo.bar", null); | ||
assertThat(logger.getLevel()).isEqualTo(parent.getLevel()); | ||
} | ||
|
||
@Test | ||
void updateLogLevelShouldThrowIAEinRootLoggerWhenLevelIsNull() { | ||
assertThatIllegalArgumentException().isThrownBy(() -> LogController.updateLogLevel("", null)) | ||
.withMessage("The level of the root logger cannot be set to null"); | ||
} | ||
|
||
} |