Update ZooKeeper Options Panel Timeout for Validation#7969
Conversation
Change timeout from 3000 to 15000 for options panel validation
Change code to use ruok/imok
…-session-time-value-for-options-panel-validation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 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)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PMD (7.23.0)Core/src/org/sleuthkit/autopsy/coordinationservice/utils/CoordinationServiceUtils.java[ERROR] Cannot load ruleset rulesets/java/basic.xml/SimplifiedTernary: Cannot resolve rule/ruleset reference 'rulesets/java/basic.xml/SimplifiedTernary'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@Core/src/org/sleuthkit/autopsy/coordinationservice/utils/CoordinationServiceUtils.java`:
- Line 35: The ZOOKEEPER_SESSION_TIMEOUT_MILLIS constant still uses 3000; update
the value of ZOOKEEPER_SESSION_TIMEOUT_MILLIS to 15000 (milliseconds) so the
validation timeout increase is applied—locate and modify the declaration of
ZOOKEEPER_SESSION_TIMEOUT_MILLIS in CoordinationServiceUtils to use 15000.
- Around line 49-63: The Socket in
CoordinationServiceUtils.validateZookeeperInstance (the block that creates new
Socket(), connects using hostName and port with
ZOOKEEPER_SESSION_TIMEOUT_MILLIS, writes "ruok", and reads response) must be
wrapped in a try-with-resources so the socket and its streams are always closed
on exceptions; move the socket creation into try (Socket socket = new Socket())
{ ... } and perform the connect(), setSoTimeout(), getOutputStream()/write/flush
and BufferedReader(InputStreamReader(socket.getInputStream()))/readLine() inside
that block, and check the readLine() result for null before calling
toLowerCase() to avoid NPE; keep the existing catch for SocketTimeoutException
to set result = false.
- Around line 60-65: The code reads a line into response via reader.readLine()
and immediately calls response.toLowerCase(), which can NPE if readLine()
returns null; update the logic in CoordinationServiceUtils (around the
response/readLine call) to null-check response before any string ops (e.g., if
(response != null && response.toLowerCase().contains("imok")) { result = true;
}) and handle the null case explicitly (treat as no-response/false or log and
continue) so the SocketTimeoutException catch remains but a potential
NullPointerException is prevented.
- Around line 56-65: The current 4LW "ruok" probe in CoordinationServiceUtils is
unsafe and may produce false negatives; update the probe code to (1) use
try-with-resources for Socket/InputStream/BufferedWriter/BufferedReader to
ensure the socket is always closed, (2) catch broader exceptions (IOException
and general Exception) not just SocketTimeoutException, (3) null-check the
response before calling response.toLowerCase(), and (4) do not treat a failed or
non-"imok" probe as a definitive false — instead return an "inconclusive" result
(e.g., null or a distinct status) so the caller in CoordinationService (which
runs the Curator connection on success) can attempt the Curator-based
connection; reference the probe block in CoordinationServiceUtils and the caller
in CoordinationService to implement the non-fatal behavior.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: ef62edab-6df6-4298-84e2-928908abc8f6
📒 Files selected for processing (1)
Core/src/org/sleuthkit/autopsy/coordinationservice/utils/CoordinationServiceUtils.java
changes based on coderabbit
Change timeout from 3000 to 15000 for options panel validation. Worked in 4.21.0 but was not long enough for 4.22.1 so I increased it.
Summary by CodeRabbit
Performance Improvements
Bug Fixes