Add topLevel validation for @MCElement annotations#2491
Conversation
WalkthroughThis PR enforces validation to prevent MCElement annotations from being marked as both topLevel=true and component=true simultaneously. It updates existing component annotations to include component=false, adds Apache License 2.0 headers across multiple files, introduces a new NullHotDeployer class, and adjusts global element filtering in Kubernetes grammar processing. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
distribution/src/test/java/com/predic8/membrane/load/LoadTester.java (1)
114-114: Redundantclose()call.The
submittersExecutorService is already declared in the try-with-resources statement (line 86-87), which will automatically close it when the block exits. This explicit call is unnecessary.🔎 Suggested fix
- submitters.close();
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
annot/src/main/java/com/predic8/membrane/annot/SpringConfigurationXSDGeneratingAnnotationProcessor.javaannot/src/main/java/com/predic8/membrane/annot/generator/ComponentClassGenerator.javaannot/src/main/java/com/predic8/membrane/annot/generator/kubernetes/Grammar.javacore/src/main/java/com/predic8/membrane/core/ExitException.javacore/src/main/java/com/predic8/membrane/core/interceptor/lang/SetBodyInterceptor.javacore/src/main/java/com/predic8/membrane/core/lang/spel/DollarTemplateParserContext.javacore/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxy.javacore/src/main/java/com/predic8/membrane/core/router/hotdeploy/DefaultHotDeployer.javacore/src/main/java/com/predic8/membrane/core/router/hotdeploy/HotDeployer.javacore/src/main/java/com/predic8/membrane/core/router/hotdeploy/NullHotDeployer.javacore/src/test/java/com/predic8/membrane/core/interceptor/lang/SetBodyInterceptorTest.javadistribution/src/test/java/com/predic8/membrane/load/LoadTester.java
🧰 Additional context used
🧬 Code graph analysis (1)
core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxy.java (2)
core/src/main/java/com/predic8/membrane/core/interceptor/flow/choice/Case.java (1)
MCElement(29-95)core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/OpenAPISpec.java (1)
MCElement(26-165)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (java)
🔇 Additional comments (14)
core/src/main/java/com/predic8/membrane/core/interceptor/lang/SetBodyInterceptor.java (1)
1-14: License header addition looks good.Standard Apache License 2.0 header with correct copyright attribution.
core/src/main/java/com/predic8/membrane/core/lang/spel/DollarTemplateParserContext.java (1)
1-14: License header addition looks good.Consistent Apache License 2.0 header format applied.
core/src/main/java/com/predic8/membrane/core/ExitException.java (1)
1-14: License header addition looks good.Consistent Apache License 2.0 header format applied.
core/src/main/java/com/predic8/membrane/core/router/hotdeploy/DefaultHotDeployer.java (1)
1-14: License header addition looks good.Consistent Apache License 2.0 header format applied.
distribution/src/test/java/com/predic8/membrane/load/LoadTester.java (3)
1-14: License header addition looks good.Consistent Apache License 2.0 header format applied.
39-51: Class structure is well-organized.Constants are appropriately documented with Javadoc comments explaining their purpose.
118-144: Async completion handling is correctly implemented.Both success and error paths properly release the semaphore and count down the latch, ensuring no resource leaks or deadlocks.
core/src/test/java/com/predic8/membrane/core/interceptor/lang/SetBodyInterceptorTest.java (1)
1-14: License header addition looks good.Consistent Apache License 2.0 header format applied.
core/src/main/java/com/predic8/membrane/core/router/hotdeploy/HotDeployer.java (1)
1-14: LGTM! License header added.The Apache License 2.0 header has been properly added to the file with no functional changes.
core/src/main/java/com/predic8/membrane/core/router/hotdeploy/NullHotDeployer.java (1)
17-32: LGTM! Proper null object implementation.The NullHotDeployer correctly implements the null object pattern with no-op methods, providing a safe default implementation for the HotDeployer interface.
annot/src/main/java/com/predic8/membrane/annot/generator/kubernetes/Grammar.java (1)
149-149: LGTM! Expands global element filter to include topLevel elements.The filter now includes elements marked with
topLevel()in addition tocomponent(), which aligns with the validation rule being introduced. This ensures topLevel elements are properly included in global element mappings.annot/src/main/java/com/predic8/membrane/annot/SpringConfigurationXSDGeneratingAnnotationProcessor.java (1)
218-220: LGTM! Validation correctly enforces topLevel/component mutual exclusivity.The validation properly prevents elements from being marked as both
topLevel=trueandcomponent=true. The placement is correct (before recording as a component), and the error message is clear.annot/src/main/java/com/predic8/membrane/annot/generator/ComponentClassGenerator.java (1)
39-39: LGTM! Annotation updated to comply with topLevel/component validation.The addition of
component=falseis necessary since the Components class is marked astopLevel=true. This change ensures compliance with the new validation rule.core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxy.java (1)
47-47: All topLevel annotations in production code are correctly configured.The addition of
component=falseto APIProxy is correct. A comprehensive search of the codebase reveals that APIProxy is the only production class with@MCElement(topLevel=true), and it now correctly includescomponent=false. The annotation processor enforces this requirement, as topLevel=true and component=true cannot coexist (the default component value is true, making explicitcomponent=falsemandatory for top-level elements).
|
This pull request needs "/ok-to-test" from an authorized committer. |
|
/ok-to-test |
Summary by CodeRabbit
New Features
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.