Skip to content

Fix testLoggerLeak by replacing Kotlin SAM lambda with anonymous object#1977

Closed
ellemac123 wants to merge 1 commit into
react:mainfrom
ellemac123:export-D108765169
Closed

Fix testLoggerLeak by replacing Kotlin SAM lambda with anonymous object#1977
ellemac123 wants to merge 1 commit into
react:mainfrom
ellemac123:export-D108765169

Conversation

@ellemac123

Copy link
Copy Markdown

Summary:
Yoga test is failing after migration from java to kotlin due to the testLoggerLeak failing. The test creates a no-op YogaLogger, sets+unsets it on a config, drops all references, then asserts that a WeakReference to the logger gets cleared by GC. The Kotlin SAM lambda form (YogaLogger { level, message -> }) ends up with an implicit this$0 capture of the enclosing test instance, so the logger never becomes weakly reachable and the test fails after 50 GC attempts.

Fix:
Replacing the SAM lambda with an explicit anonymous object expression to match what the Java version was doing.

Reviewed By: cortinico

Differential Revision: D108765169

Summary:
Yoga test is failing after migration from java to kotlin due to the `testLoggerLeak` failing. The test creates a no-op `YogaLogger`, sets+unsets it on a config, drops all references, then asserts that a `WeakReference` to the logger gets cleared by GC. The Kotlin SAM lambda form (`YogaLogger { level, message -> }`) ends up with an implicit `this$0` capture of the enclosing test instance, so the logger never becomes weakly reachable and the test fails after 50 GC attempts.

Fix:
Replacing the SAM lambda with an explicit anonymous object expression to match what the Java version was doing.

Reviewed By: cortinico

Differential Revision: D108765169
@meta-cla meta-cla Bot added the CLA Signed label Jun 17, 2026
@meta-codesync

meta-codesync Bot commented Jun 17, 2026

Copy link
Copy Markdown

@ellemac123 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108765169.

@cortinico cortinico left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync Bot closed this in ef2efc5 Jun 17, 2026
@meta-codesync meta-codesync Bot added the Merged label Jun 17, 2026
@meta-codesync

meta-codesync Bot commented Jun 17, 2026

Copy link
Copy Markdown

This pull request has been merged in ef2efc5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants