Fix CI flake: JavaSEPortFontMappingTest leaks JavaSEPort.instance#5063
Merged
Conversation
JavaSEPortFontMappingTest constructs `new JavaSEPort()` inside two of its tests; the JavaSEPort constructor unconditionally assigns `instance = this`, so the throwaway port leaks into the global static. If CodenameOneExtensionTest then runs in the same JVM after Display has already been initialized (e.g. by PaintScopeTest), the extension's @LargerText / @orientation handling mutates the wrong port via JavaSEPort.instance while Display.impl still references the original, and the assertions read stale defaults. The bug is order-dependent: master's recent CI runs happened to pick a test order where CodenameOneExtensionTest ran first, so the leak was masked; PR runs that interleaved PaintScopeTest, FontMappingTest, and CodenameOneExtensionTest in the failing order surfaced it as two test failures ("expected: <1.6> but was: <1.0>", "expected: <true> but was: <false>"). Capture JavaSEPort.instance in @beforeeach and restore it in @AfterEach so the test no longer leaks across test classes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Collaborator
Author
|
Compared 47 screenshots: 47 matched. |
Collaborator
Author
|
Compared 116 screenshots: 116 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Collaborator
Author
|
Compared 116 screenshots: 116 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 116 screenshots: 116 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
JavaSEPortFontMappingTestconstructsnew JavaSEPort()inside two tests, and the constructor unconditionally assignsinstance = this, so the throwaway port leaks into the global static.CodenameOneExtensionTestruns in the same JVM afterDisplayhas already been initialized (e.g. byPaintScopeTest), the extension's@LargerText/@Orientationhandling mutates the wrong port viaJavaSEPort.instancewhileDisplay.implstill references the original — assertions then read stale defaults (1.0 / landscape).CodenameOneExtensionTestfirst and passed; the 07:33 PR run picked the failing interleaving and surfaced two failures.Fix: capture
JavaSEPort.instancein@BeforeEachand restore it in@AfterEachso this test no longer leaks across test classes. It is the only test in the repo that constructsnew JavaSEPort(), so this single change closes the flake.Test plan
mvn -pl javase test -Plocal-dev-javase— all 70 tests pass.new JavaSEPort(), runCodenameOneExtensionTest) reproduced the CI failure verbatim before the fix.JavaSEPortFontMappingTest's@BeforeEach/@AfterEachpasses with the fix.🤖 Generated with Claude Code