Disable plugin loading on illegal/ not set plugin dir#86
Conversation
WalkthroughThe changes modify the Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 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)
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.
🧹 Nitpick comments (1)
src/test/java/org/cryptomator/integrations/common/ClassLoaderFactoryTest.java (1)
115-118: Consider cleaning up system property inafterEach.The
MockedStaticcleanup is correct. However, tests in this class (including existing ones at lines 72 and 95) modify thecryptomator.pluginDirsystem property without restoring its original state. This could cause test interference depending on execution order.♻️ Suggested improvement
+ String originalPluginDir; + `@BeforeEach` public void beforeEach() { + originalPluginDir = System.getProperty("cryptomator.pluginDir"); mockedClass = Mockito.mockStatic(ClassLoaderFactory.class); mockedClass.when(() -> ClassLoaderFactory.forPluginDir()).thenCallRealMethod(); mockedClass.when(() -> ClassLoaderFactory.forPluginDirWithPath(any())).thenReturn(null); } `@AfterEach` public void afterEach() { mockedClass.close(); + if (originalPluginDir == null) { + System.clearProperty("cryptomator.pluginDir"); + } else { + System.setProperty("cryptomator.pluginDir", originalPluginDir); + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/org/cryptomator/integrations/common/ClassLoaderFactoryTest.java` around lines 115 - 118, The tests modify the system property "cryptomator.pluginDir" but never restore it; update the test class to save the original value (e.g., a private String originalPluginDir) before tests run and restore it in the existing afterEach() method (after mockedClass.close()) so the property is either reset to the saved value or removed if it was originally null. Locate the setup where "cryptomator.pluginDir" is changed and add code to capture System.getProperty("cryptomator.pluginDir") into originalPluginDir, and in afterEach() perform conditional restore via System.setProperty or System.clearProperty accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/test/java/org/cryptomator/integrations/common/ClassLoaderFactoryTest.java`:
- Around line 115-118: The tests modify the system property
"cryptomator.pluginDir" but never restore it; update the test class to save the
original value (e.g., a private String originalPluginDir) before tests run and
restore it in the existing afterEach() method (after mockedClass.close()) so the
property is either reset to the saved value or removed if it was originally
null. Locate the setup where "cryptomator.pluginDir" is changed and add code to
capture System.getProperty("cryptomator.pluginDir") into originalPluginDir, and
in afterEach() perform conditional restore via System.setProperty or
System.clearProperty accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4532f0aa-2c4d-43d2-a895-2cc14dfc0248
📒 Files selected for processing (2)
src/main/java/org/cryptomator/integrations/common/ClassLoaderFactory.javasrc/test/java/org/cryptomator/integrations/common/ClassLoaderFactoryTest.java
Only search directories, if pluginDir property is set and valid