Skip to content

CoreCLR test failure: Java.InteropTests.JavaObjectTest.Dispose_Finalized #10358

Open

Description

@jonathanpeppers

Android framework version

net10.0-android (Preview)

Affected platform version

.NET 10

Description

After merging #10354, a couple test runs are successful, but then one failed:

Mono.Android.NET_Tests, Java.InteropTests.JavaObjectTest.Dispose_Finalized / Release

System.AggregateException : AggregateException_ctor_DefaultMessage (  Expected: True
But was:  False
)
----> NUnit.Framework.AssertionException :   Expected: True
But was:  False

Test source:

So, I suspect the test is flaky and fails some percentage of the time.

We should check out if this is a bug, or if the test can be improved.

Steps to Reproduce

Run tests\Mono.Android-Tests\Mono.Android-Tests\Mono.Android.NET-Tests.csproj several times

Did you find any workaround?

Run it again, it passes sometimes.

Relevant log output

logcat-ReleaseCoreCLR-Mono.Android.NET_Tests (12).txt

Activity

  1. added
    Area: App Runtime
    needs-triage
    and removed
    needs-triage
    on Jul 30, 2025
  2. added this to the .NET 10 milestone on Jul 30, 2025
  3. jonathanpeppers commented on Jul 30, 2025

    @jonathanpeppers
    MemberAuthor

    /cc @simonrozsival if you want to take a look

  4. moved this from Todo to Consideration in .NET for Android Backlogon Jul 30, 2025
  5. simonrozsival commented on Jul 31, 2025

    @simonrozsival
    Member

    @jonathanpeppers I was not able to reproduce the test failure. The test is passing for me in both Debug and Release configuration with CoreCLR 🤔

  6. jonathanpeppers commented on Jul 31, 2025

    @jonathanpeppers
    MemberAuthor

    It could be a rare/race condition type thing.

    I was looking and for some reason our CI is still API 29:

    <TestAvdApiLevel Condition=" '$(TestAvdApiLevel)' == '' ">29</TestAvdApiLevel>

    So, I can try updating this in the meantime.

  7. jonathanpeppers commented on Aug 18, 2025

    @jonathanpeppers
    MemberAuthor

    This hasn't happened again yet. Will reopen if it does.

  8. locked and limited conversation to collaborators on Sep 18, 2025
  9. simonrozsival commented on Jul 13, 2026

    @simonrozsival
    Member

    Recurrence (net11.0, Debug)

    This failed again, so reopening per the note above ("Will reopen if it does").

    • Build: dnceng-public build 1506492
    • Test: Java.InteropTests.JavaObjectTest.Dispose_Finalized
    • Config: net11.0-android (net11.0 | x64), Debug — bin/TestDebug/net11.0-android/Mono.Android.NET-Tests.dll
    failed Dispose_Finalized
        Expected JavaDisposedObject.Dispose(disposing: false) to run.
      Expected: True
      But was:  False
    
       at Java.InteropTests.JavaObjectTest.WaitForGC(Func`1 predicate, String message, Int32 timeoutMilliseconds)
       at Java.InteropTests.JavaObjectTest.Dispose_Finalized()
       at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
       at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
       at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
       at NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(TestExecutionContext context)
       at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
       at NUnit.Framework.Internal.Execution.SimpleWorkItem.<>c__DisplayClass4_0.<PerformWork>b__0()
       at NUnit.Framework.Internal.ContextUtils.<>c__DisplayClass1_0`1.<DoIsolated>b__0(Object _)
      from /Users/runner/work/1/s/bin/TestDebug/net11.0-android/Mono.Android.NET-Tests.dll (net11.0|x64)
    

    Notes since this was last closed

    The test was reworked to be deterministic in dotnet/java-interop#1408 (merged 2026-04-21), following the earlier dotnet/java-interop#1338. The current implementation waits on the finalizer/collection condition directly, bounded to a 2000 ms timeout in WaitForGC:

    static async Task WaitForGC (Func<bool> predicate, string message, int timeoutMilliseconds = 2000)

    Source: external/Java.Interop/tests/Java.Interop-Tests/Java.Interop/JavaObjectTest.cs (dotnet/java-interop).

    This failure means the finalizer path (Dispose(disposing: false)) did not run within that 2 s window — i.e. the determinism rework reduced but did not eliminate the timing dependence, plausibly on a slow/loaded CI device. Worth considering a longer/adaptive timeout or a more robust wait for the GC-bridge + finalizer to complete.

    Related

  10. added
    flaky-ci
    on Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App Runtimeflaky-ci

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions