[
https://issues.apache.org/jira/browse/GROOVY-12573?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18134525#comment-18134525
]
ASF GitHub Bot commented on GROOVY-12573:
-----------------------------------------
codeconsole opened a new pull request, #3101:
URL: https://github.com/apache/groovy/pull/3101
`LogTest.registerLogFormatterSpy` added a handler to
`Logger.getLogger(name)` and kept no reference to the logger. The `LogManager`
holds loggers weakly, so a garbage collection before the class under test
initialized dropped it, and the class's own `Logger.getLogger(name)` returned a
new logger without the spy; `testDefaultCategory` failed on CI that way. The
test now keeps each spied logger until it ends.
`testSpyIsKeptWhenGarbageIsCollectedBeforeTheClassLogs` forces the collection
and fails without the change. Test code only.
The `groovy-logging-test` tests pass (107), as do the Checkstyle and
CodeNarc gates.
> LogTest loses its spy handler when the logger is garbage collected before the
> class under test logs
> ---------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12573
> URL: https://issues.apache.org/jira/browse/GROOVY-12573
> Project: Groovy
> Issue Type: Test
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {{LogTest.registerLogFormatterSpy}} adds a handler to
> {{Logger.getLogger(name)}} without keeping the logger. The {{LogManager}}
> holds loggers weakly, so a garbage collection before the class under test
> initializes drops the logger, and the class gets a new one without the spy;
> {{testDefaultCategory}} then fails (seen on CI).
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)