feat: improve error message when a declarative supplier is missing in Quarkus#1687
Conversation
… Quarkus Does not affect Spring since Spring does not generate it own member accessors.
triceo
left a comment
There was a problem hiding this comment.
LGTM, with small adjustments.
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the error reporting when a declarative shadow‐variable’s supplier method is missing, and adds end‐to‐end tests in both Quarkus and Spring to verify the improved message.
- Added Spring test domain and configuration for missing supplier variable error
- Added Quarkus test domain and processor logic to detect missing supplier and throw a clear exception
- Updated core and Quarkus processor code to validate supplier method existence and format a detailed error
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| spring-integration/.../TestdataSpringMissingSupplierVariableSolution.java | New Spring test solution for missing supplier variable |
| spring-integration/.../TestdataSpringMissingSupplierVariableEntity.java | New entity with @ShadowVariable to trigger missing-supplier case |
| spring-integration/.../TimefoldSolverAutoConfigurationTest.java | Added missingSupplierVariables test to assert Spring error |
| quarkus-integration/quarkus/.../TimefoldProcessor.java | Validates supplier method existence, throws improved exception |
| core/src/main/.../DeclarativeShadowVariableDescriptor.java | Improved error message when supplier method is not found |
| quarkus-integration/quarkus/.../TestdataQuarkusDeclarativeMissingSupplierValue.java | New Quarkus test entity missing supplier methods |
| quarkus-integration/quarkus/.../TimefoldProcessorMissingSupplierForDeclarativeVariableTest.java | Added Quarkus unit test for missing supplier declarative var |
Comments suppressed due to low confidence (5)
quarkus-integration/quarkus/deployment/src/test/java/ai/timefold/solver/quarkus/testdomain/suppliervariable/missing/TestdataQuarkusDeclarativeMissingSupplierSolution.java:60
- [nitpick] The
toString()output usesTestdataDeclarativeMissingSupplierSolutionbut the class is namedTestdataQuarkusDeclarativeMissingSupplierSolution. Update the string for consistency.
return "TestdataDeclarativeMissingSupplierSolution{" +
quarkus-integration/quarkus/deployment/src/test/java/ai/timefold/solver/quarkus/testdomain/suppliervariable/missing/TestdataQuarkusDeclarativeMissingSupplierEntity.java:52
- [nitpick] The
toString()usesTestdataDeclarativeMissingSupplierEntitybut the class name includesQuarkus. Align the string toTestdataQuarkusDeclarativeMissingSupplierEntityfor clarity.
return "TestdataDeclarativeMissingSupplierEntity{" +
spring-integration/spring-boot-autoconfigure/src/test/java/ai/timefold/solver/spring/boot/autoconfigure/missingsuppliervariable/constraints/TestdataSpringMissingSupplierVariableConstraintProvider.java:23
- Throwing
new IllegalStateException()without a message makes debugging harder. Consider providing a descriptive message to explain why the exception is thrown (e.g., "shadow variable not initialized before constraint").
throw new IllegalStateException();
quarkus-integration/quarkus/deployment/src/main/java/ai/timefold/solver/quarkus/deployment/TimefoldProcessor.java:1046
- The multiline string literal for this exception message starts with a newline and indentation, which will introduce unwanted whitespace in the error output. Consider moving the first
"""up to the same line as the annotation or trimming leading whitespace.
throw new IllegalArgumentException("""
core/src/main/java/ai/timefold/solver/core/impl/domain/variable/declarative/DeclarativeShadowVariableDescriptor.java:54
- Leading newline and indentation in this multiline exception message will show extra whitespace. It’s clearer to start the text immediately after the opening
"""or use.stripIndent()to clean it up.
throw new IllegalArgumentException("""
|



Does not affect Spring since Spring does not generate it own member accessors.