Fix OidcMetaData MissingImplementation error by removing flawed class path-based test detection#217
Conversation
…path-based test detection
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughRemoved test-environment detection from the Guice module so Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
kinde-management/src/test/java/com/kinde/KindeAdminSessionBuilderTest.java (1)
38-53:⚠️ Potential issue | 🟠 MajorProtect singleton teardown with
finallyto avoid test-state leakage.Lines 51-52 only run on the happy path. If initialization/build/assertion fails earlier, global singleton state can leak into subsequent tests and cause flakiness.
Proposed fix
public void testApp() { // Initialize Guice with test modules KindeEnvironmentSingleton.init(KindeEnvironmentSingleton.State.TEST); - KindeGuiceSingleton.init( - new KindeManagementGuiceTestModule(), - new KindeTokenGuiceTestModule()); - - KindeClient kindeClient = KindeClientBuilder.builder().build(); - KindeAdminSession kindeAdminSession1 = KindeAdminSessionBuilder.builder().build(); - KindeAdminSession kindeAdminSession2 = KindeAdminSessionBuilder.builder().client(kindeClient).build(); - assertTrue( kindeAdminSession1 != kindeAdminSession2 ); - - // Clean up - KindeGuiceSingleton.fin(); - KindeEnvironmentSingleton.fin(); + try { + KindeGuiceSingleton.init( + new KindeManagementGuiceTestModule(), + new KindeTokenGuiceTestModule()); + + KindeClient kindeClient = KindeClientBuilder.builder().build(); + KindeAdminSession kindeAdminSession1 = KindeAdminSessionBuilder.builder().build(); + KindeAdminSession kindeAdminSession2 = KindeAdminSessionBuilder.builder().client(kindeClient).build(); + assertTrue( kindeAdminSession1 != kindeAdminSession2 ); + } finally { + try { + KindeGuiceSingleton.fin(); + } finally { + KindeEnvironmentSingleton.fin(); + } + } }As per coding guidelines: focus on error handling and test coverage/quality.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@kinde-management/src/test/java/com/kinde/KindeAdminSessionBuilderTest.java` around lines 38 - 53, Wrap the test setup and assertions in a try-finally so singletons are always torn down: move KindeEnvironmentSingleton.init and KindeGuiceSingleton.init (called in testApp) before the try, put the KindeClientBuilder/KindeAdminSessionBuilder calls and assertions inside the try block, and call KindeGuiceSingleton.fin() and KindeEnvironmentSingleton.fin() in the finally block to guarantee cleanup even on failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@kinde-j2ee/src/test/java/com/kinde/servlet/KindeSingletonTest.java`:
- Around line 37-46: The test currently initializes shared singletons
(KindeEnvironmentSingleton.init, KindeGuiceSingleton.init) and calls
KindeSingleton.getInstance but performs teardown (KindeGuiceSingleton.fin,
KindeEnvironmentSingleton.fin) unguarded; wrap the usage in a try/finally so
fin() is always called even if getInstance or assertions throw, or alternatively
move the fin() calls into a tearDown() method to guarantee cleanup; ensure both
KindeGuiceSingleton.fin and KindeEnvironmentSingleton.fin are invoked inside the
finally/tearDown to prevent singleton state leaking into other tests.
---
Outside diff comments:
In `@kinde-management/src/test/java/com/kinde/KindeAdminSessionBuilderTest.java`:
- Around line 38-53: Wrap the test setup and assertions in a try-finally so
singletons are always torn down: move KindeEnvironmentSingleton.init and
KindeGuiceSingleton.init (called in testApp) before the try, put the
KindeClientBuilder/KindeAdminSessionBuilder calls and assertions inside the try
block, and call KindeGuiceSingleton.fin() and KindeEnvironmentSingleton.fin() in
the finally block to guarantee cleanup even on failures.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: bfd80fed-913a-4f15-948c-3d086cb035e3
📒 Files selected for processing (2)
kinde-j2ee/src/test/java/com/kinde/servlet/KindeSingletonTest.javakinde-management/src/test/java/com/kinde/KindeAdminSessionBuilderTest.java
kinde-j2ee/src/test/java/com/kinde/servlet/KindeSingletonTest.java
Outdated
Show resolved
Hide resolved
…tate leaking on failure
…ingleton state leaking on failure
|
@coderabbitai resume |
✅ Actions performedReviews resumed. |
Checking for JUnit in the classpath was was always true causing the implementation error. JUnit check was removed as this was simply not a correct check.
Checklist
🛟 If you need help, consider asking for advice over in the Kinde community.
Summary by CodeRabbit