fix(starter): harden auto-configuration and fluent findBySpec robustness - #188
Closed
shihyuho wants to merge 1 commit into
Closed
fix(starter): harden auto-configuration and fluent findBySpec robustness#188shihyuho wants to merge 1 commit into
shihyuho wants to merge 1 commit into
Conversation
COR-13: fluent findBySpec(Object, Function) now substitutes an unrestricted specification when mapping yields null, so empty/null criteria return all rows (via the fluent query) instead of throwing IllegalArgumentException, matching every sibling *BySpec method. COR-12: the JpaRepositoryFactoryBeanPostProcessor @bean is now static and injects ObjectProvider<RepositoryFactoryCustomizer>, resolved lazily inside postProcessBeforeInitialization, so registering the BeanPostProcessor no longer force-instantiates customizer beans (or the enclosing config) during BPP registration. MAINT-02: SpecMapperAutoConfiguration is now @autoConfiguration(after = JpaRepositoriesAutoConfiguration.class), making the nested @ConditionalOnBean(JpaRepositoryFactoryBean) gate ordering contractual rather than dependent on alphabetical FQCN sorting. Refs #178 Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
shihyuho
commented
Jul 16, 2026
shihyuho
left a comment
Member
Author
There was a problem hiding this comment.
ABSTAIN — the commits check is red and is not attributable to this diff; human review advised
All 9 axes were reviewed and none produced a must-fix finding. The verdict is capped at abstain only because a red check may never be approved over: commits failed while pulling the wagoid/commitlint-github-action:6.2.1 image from Docker Hub — three retries, each Client.Timeout exceeded while awaiting headers — so it never reached the point of linting any commit, and this diff touches no CI configuration. Re-running that job should clear it. This is not a judgement on the code.
Non-blocking (2)
- FYI · Architecture —
starter/src/main/java/tw/com/softleader/data/jpa/spec/starter/repository/support/JpaRepositoryFactoryBeanPostProcessor.java:40— the public constructor's parameter type changes fromList<RepositoryFactoryCustomizer>toObjectProvider<RepositoryFactoryCustomizer>, a source- and binary-breaking change to a published public type that ships under afix:(patch) release with no deprecation window. - Nit · Test coverage —
starter/src/main/java/tw/com/softleader/data/jpa/spec/starter/autoconfigure/SpecMapperAutoConfiguration.java:116— the COR-12 change ships with no test asserting its actual payload (that customizer beans are no longer force-instantiated during theBeanPostProcessorregistration phase), so a future revert to a non-static@Beanor an eagerListparameter would reintroduce the silent proxy-loss bug with fully green CI.
Coverage & checks
| Axis | Status |
|---|---|
| Correctness | clean — traced the COR-13 null path end to end and confirmed the assertion being avoided against SimpleJpaRepository.doFindBy in spring-data-jpa 3.5.9; confirmed toSpec returns null for both a null rootObject and all-empty criteria, so one ternary covers both |
| Spec conformance | clean — checked all six stated acceptance criteria and the three in-scope findings (COR-13, COR-12, MAINT-02) against the sources at the head SHA |
| Scope | clean — all four changed files trace to a named finding of the linked issue; import churn checked for unrelated drift |
| Convention | clean — AGENTS.md's commit-hygiene rule is explicitly CI-enforced (skipped per the charter); CONTRIBUTING.md checked rule by rule; the PR title is a well-formed conventional commit |
| Security | clean — no string-built queries (the substituted spec contributes no predicate), no secrets, no authz surface touched |
| Readability | clean — 2 lines replace 1, flat ternary; orphaned imports removed exactly where the change orphaned them, with no unrelated pruning |
| Architecture | 1 finding |
| Performance | clean — orderedStream() now resolves per factory bean, but getBeanNamesForType is served from the frozen allBeanNamesByType cache, so the cost is not material |
| Test coverage | 1 finding |
- Verified —
continuous-integration/jenkins/branch,continuous-integration/jenkins/pr-mergeandpr-titlegreen;commitsred — Docker Hub image-pull timeout, see the verdict above (all read viagh pr checks, never run locally) - Out-of-band — read
QueryBySpecExecutorAdapter,SpecCodec/SpecMapperand the new test at the head SHA · cross-checkedSimpleJpaRepository.doFindBy'sAssert.notNull(spec, ...)against the pinned spring-data-jpa 3.5.9 source · tracedDefaultListableBeanFactory.getBeanNamesForTypecaching to dismiss theorderedStream()performance candidate
🤖 Reviewed by Claude Opus 4.8
(self-review — same account; GitHub records this as event=COMMENT with no badge, so the verdict above is advisory.)
This was referenced Jul 20, 2026
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
Hardens the starter's auto-configuration lifecycle and the fluent query API (WP6):
findBySpec(Object, Function)now tolerates empty/null criteria like every sibling*BySpecmethod, substituting an unrestricted specification when mapping yieldsnullinstead of letting Spring Data'sfindBythrowIllegalArgumentException("Specification must not be null").JpaRepositoryFactoryBeanPostProcessor@Beanis nowstaticand injectsObjectProvider<RepositoryFactoryCustomizer>(resolved lazily insidepostProcessBeforeInitialization), so registering thisBeanPostProcessorno longer force-instantiates customizer beans or the enclosing configuration class during the BPP registration phase.SpecMapperAutoConfigurationis now@AutoConfiguration(after = JpaRepositoriesAutoConfiguration.class), making the nested@ConditionalOnBean(JpaRepositoryFactoryBean.class)gate ordering contractual instead of dependent on alphabetical FQCN sorting.MAINT-05 (API parity) is intentionally out of scope per the agent brief.
Closes #178
Acceptance criteria
findBySpec(Object, Function)with empty criteria (all fields null) returns the fluent result over all rows rather than throwing;nullcriteria behaves identically to the other*BySpecmethods.findByEmptySpecAndQuerymirrorsfindByEmptySpecfor the fluent variant (FetchableFluentQuery::allwith empty criteria) and asserts all rows are returned.@BeanproducingJpaRepositoryFactoryBeanPostProcessorno longer eagerly resolves aList<RepositoryFactoryCustomizer>; customizers are supplied lazily viaObjectProviderresolved insidepostProcessBeforeInitialization, and the method isstatic.JpaRepositoryFactoryBeanPostProcessorstill applies every registeredRepositoryFactoryCustomizerto eachJpaRepositoryFactoryBeanit post-processes (viacustomizers.orderedStream()).SpecMapperAutoConfigurationis declared as a proper auto-configuration ordered afterJpaRepositoriesAutoConfiguration.Testing
mvn testacross all modules — BUILD SUCCESS.mapper(96 tests) andstarter(16 tests, including the newfindByEmptySpecAndQuery) both green.Warning
Higher-risk auto-configuration change. Please closely review the auto-config lifecycle/ordering: the
@AutoConfiguration(after = ...)ordering, thestatic@Bean+ lazyObjectProviderresolution timing relative toBeanPostProcessorregistration, and note thatSpecMapperAutoConfigurationis shared with the deferred WP1/#173 — coordinate to avoid conflicts.