Skip to content

Simplify configuration/configLocation mutual exclusion check#1244

Open
wlswo wants to merge 1 commit into
mybatis:masterfrom
wlswo:simplify-config-mutex-check
Open

Simplify configuration/configLocation mutual exclusion check#1244
wlswo wants to merge 1 commit into
mybatis:masterfrom
wlswo:simplify-config-mutex-check

Conversation

@wlswo
Copy link
Copy Markdown

@wlswo wlswo commented May 22, 2026

Summary

Resolves the // TODO Review this statement as it seems off! comment in SqlSessionFactoryBean.afterPropertiesSet() by simplifying the boolean expression to its logically equivalent minimal form, and fixes a minor grammatical issue in the error message.

Logical equivalence

Let A = (configuration == null) and B = (configLocation == null).

Original expression:

(A && B) || !(¬A && ¬B)

By De Morgan's law: !(¬A && ¬B) ≡ A || B, so the expression becomes (A && B) || (A || B). By absorption (A && B implies A || B), this reduces to A || B.

The simplified expression preserves the original semantics: at least one of configuration or configLocation must be null — i.e. they cannot both be specified.

Changes

  • SqlSessionFactoryBean.afterPropertiesSet(): simplified the boolean
    expression and removed the now-resolved TODO comment.
  • Fixed minor grammar in the error message:
    • Before: "can not specified with together"
    • After: "can not be specified together"
  • Updated SqlSessionFactoryBeanTest.testSpecifyConfigurationAndConfigLocation
    to assert against the new error message.

Verification

./mvnw verify — BUILD SUCCESS, 222 tests, 0 failures, 15 skipped (same as baseline).

The boolean expression in SqlSessionFactoryBean.afterPropertiesSet()
was logically equivalent to a much simpler form. This change replaces
it with the minimal equivalent expression and resolves the existing
TODO comment.

Also fixes a minor grammatical issue in the error message
('can not specified with together' -> 'can not be specified together')
and updates the corresponding test assertion.
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.

1 participant