Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ class SentryLog4j2AppenderAutoConfigurationTest {

private val originalLogManagerFactory = LogManager.getFactory()

private val loggerContext: LoggerContext
get() = LogManager.getContext(false) as LoggerContext
// Log4j2 holds LoggerContexts weakly, so a GC during context startup would replace this one
// (and drop appenders added by a test) unless the test keeps it reachable.
private lateinit var loggerContext: LoggerContext

private val configuration
get() = loggerContext.configuration
Expand All @@ -85,6 +86,7 @@ class SentryLog4j2AppenderAutoConfigurationTest {
fun `reset Log4j2 context`() {
useLog4j2Core()
resetLog4j2Context()
loggerContext = LogManager.getContext(false) as LoggerContext
}

@AfterTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ class SentryLog4j2AppenderAutoConfigurationTest {

private val originalLogManagerFactory = LogManager.getFactory()

private val loggerContext: LoggerContext
get() = LogManager.getContext(false) as LoggerContext
// Log4j2 holds LoggerContexts weakly, so a GC during context startup would replace this one
// (and drop appenders added by a test) unless the test keeps it reachable.
private lateinit var loggerContext: LoggerContext

private val configuration
get() = loggerContext.configuration
Expand All @@ -85,6 +86,7 @@ class SentryLog4j2AppenderAutoConfigurationTest {
fun `reset Log4j2 context`() {
useLog4j2Core()
resetLog4j2Context()
loggerContext = LogManager.getContext(false) as LoggerContext
}

@AfterTest
Expand Down
Loading