Skip to content

Conversation

@Wang-Benjamin
Copy link

Problem

When the test execution order is changed, all five tests in file TkMapperServiceTest.java would show a non-deterministic behavior and output the following errors of two kinds:

  • IllegalArgumentException: wrong number of arguments
  • IllegalMonitorStateException: current thread is not owner

The root cause of these errors is that Salon generates a subclass proxy for the test class. When the test methods are non-final, the proxy would override them and route calls through Solon's AOP chain. With NonDex randomizing the iteration order, this proxy path intermittently mis-invokes methods and the above errors would be generated.

Commands to reproduce the errors:

mvn -pl solon-plugin -Dcheckstyle.skip=true -Drat.skip=true \
    edu.illinois:nondex-maven-plugin:2.1.7:nondex \
    -Dtest=tk.mybatis.solon.test.service.TkMapperServiceTest#testName \ -- replace with the actual test name
    -DnondexRuns=10 |& tee nondex-$(date +%s).log

Proposed Fix

The code changes are local and minimum. By changing the test method to final, we can avoid Solon overriding or intercepting them.

Involved Tests

  • TkMapperServiceTest.all
  • TkMapperServiceTest.byId
  • TkMapperServiceTest.exampleQuery
  • TkMapperServiceTest.rawMybatisQuery
  • TkMapperServiceTest.logicDelInsert

@abel533 abel533 requested a review from Copilot October 9, 2025 09:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses non-deterministic test behavior in TkMapperServiceTest by making all test methods final to prevent Solon's AOP proxy from overriding them and causing intermittent execution issues.

  • Added final modifier to five test methods to prevent proxy interference
  • Resolves IllegalArgumentException and IllegalMonitorStateException errors that occur when test execution order changes
  • Maintains existing test functionality while ensuring deterministic behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@abel533 abel533 merged commit 38ee3a9 into abel533:master Oct 10, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants