Configure loader timeout and fix plugin component display#478
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@owlplug-client/src/main/java/com/owlplug/core/controllers/OptionsController.java`:
- Around line 175-188: The loaderTimeoutTextField listener currently accepts any
parsed long and persists it, which can overflow when converted to milliseconds
downstream; update the listener in OptionsController so that after parsing the
newValue you validate it against a safe maximum (e.g., define a
MAX_LOADER_TIMEOUT_SECONDS constant) or ensure timeout <= Long.MAX_VALUE / 1000
before persisting and calling nativeHostService.setScannerTimeout; if the value
is out of range, either clamp to the max or ignore the input and do not call
getPreferences().putLong(ApplicationDefaults.NATIVE_LOADER_TIMEOUT_KEY, ...) nor
nativeHostService.setScannerTimeout(...). Also consider using Math.multiplyExact
or an overflow-safe check when any code converts seconds to milliseconds.
- Around line 317-318: Replace the hardcoded 30L fallback with the canonical
default constant from ApplicationDefaults so the UI uses the same startup
default used when preferences are initialized: change the call using
getPreferences().getLong(ApplicationDefaults.NATIVE_LOADER_TIMEOUT_KEY, 30L) to
pass the ApplicationDefaults default constant (the associated timeout default
defined in ApplicationDefaults) instead of 30L so loaderTimeoutTextField shows
the same initial value as preference initialization.
In
`@owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginInfoController.java`:
- Around line 204-209: The code only updates lastScanErrorLabel when
plugin.getFootprint() is non-null, leaving stale error text visible when the
footprint is absent; modify the if block around plugin.getFootprint() (the
section that sets nativeDiscoveryToggleButton, scanError, and
lastScanErrorLabel) to add an else branch that clears and hides
lastScanErrorLabel (e.g., setText("") and setVisible(false)) and also ensure
nativeDiscoveryToggleButton is set to a safe default in that else to avoid stale
state.
In
`@owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTableController.java`:
- Around line 210-214: The selection loop in selectPluginById compares
IPlugin.getId() across heterogeneous entities (Plugin and PluginComponent),
causing cross-entity collisions; restrict the check to actual Plugin instances
and use a consistent primitive comparison: inside selectPluginById iterate
pluginList, first ensure the item is a Plugin (e.g., if (plugin instanceof
Plugin) { Plugin p = (Plugin) plugin; if (p.getId() == id) {
tableView.getSelectionModel().select(p); break; } }), or if getId() returns Long
use Long.valueOf(id).equals(p.getId()) after the instanceof check; this
guarantees you only match Plugin entities and avoids ID type mismatches.
In
`@owlplug-client/src/main/java/com/owlplug/plugin/services/NativeHostService.java`:
- Around line 56-57: Centralize validation and seconds→milliseconds conversion
by adding a setScannerTimeout(long seconds) method (or updating the existing
one) that: checks for negative input and clamps to a safe minimum (e.g., 0 or a
default), computes milliseconds using a checked multiply to avoid overflow
(e.g., guard seconds > Long.MAX_VALUE/1000 and cap to Long.MAX_VALUE or
Long.MAX_VALUE/1000*1000), and then calls
EmbeddedScannerPluginLoader.getInstance().setTimeout(milliseconds); then replace
direct multiplications in init() (the call setting timeoutSeconds * 1000) and
the other site around lines 116-118 to call setScannerTimeout(timeoutSeconds) so
all conversion and validation is centralized in that method.
In `@owlplug-host/src/main/java/com/owlplug/host/io/CommandRunner.java`:
- Around line 78-80: In the InterruptedException catch in CommandRunner (catch
block that currently throws new IOException("Process execution interrupted", e))
restore the thread's interrupt status before throwing by calling
Thread.currentThread().interrupt(), then re-throw the IOException; apply the
same change in PlatformUtils where InterruptedException is caught (the catch
at/around the existing throw on line ~80) so cooperative cancellation isn't
swallowed—i.e., call Thread.currentThread().interrupt() immediately inside each
InterruptedException handler, then throw the IOException as before.
In
`@owlplug-host/src/main/java/com/owlplug/host/loaders/EmbeddedScannerPluginLoader.java`:
- Around line 133-138: The current exit-code check in
EmbeddedScannerPluginLoader treats any non-negative exit value as success;
update the condition that checks result.getExitValue() in the method that calls
createPluginsFromCommandOutput(...) so it only treats 0 as success (use
result.getExitValue() == 0) and throw NativeLoaderException for any non-zero
exit code, ensuring failing scanner exits do not proceed to XML extraction.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 33372e5c-232b-48b6-8163-871aaaab5a44
📒 Files selected for processing (20)
owlplug-client/src/main/java/com/owlplug/core/components/ApplicationDefaults.javaowlplug-client/src/main/java/com/owlplug/core/controllers/OptionsController.javaowlplug-client/src/main/java/com/owlplug/core/services/OptionsService.javaowlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginInfoController.javaowlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTableController.javaowlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTreeViewController.javaowlplug-client/src/main/java/com/owlplug/plugin/model/IPlugin.javaowlplug-client/src/main/java/com/owlplug/plugin/model/Plugin.javaowlplug-client/src/main/java/com/owlplug/plugin/model/PluginComponent.javaowlplug-client/src/main/java/com/owlplug/plugin/model/PluginFootprint.javaowlplug-client/src/main/java/com/owlplug/plugin/services/NativeHostService.javaowlplug-client/src/main/java/com/owlplug/plugin/tasks/PluginScanTask.javaowlplug-client/src/main/resources/fxml/OptionsView.fxmlowlplug-client/src/main/resources/fxml/plugins/PluginInfoView.fxmlowlplug-host/src/main/java/com/owlplug/host/io/CommandRunner.javaowlplug-host/src/main/java/com/owlplug/host/loaders/DummyPluginLoader.javaowlplug-host/src/main/java/com/owlplug/host/loaders/EmbeddedScannerPluginLoader.javaowlplug-host/src/main/java/com/owlplug/host/loaders/NativeLoaderException.javaowlplug-host/src/main/java/com/owlplug/host/loaders/NativePluginLoader.javaowlplug-host/src/main/java/com/owlplug/host/loaders/jni/JNINativePluginLoader.java
2cd8fe1 to
0e7357e
Compare
Resolves #477
Content