[ZEPPELIN-6462] Close interpreter-setting.json streams with try-with-resources #5355
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 294 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.340
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5355"
general
weight: 0.35
Reamer
What is this PR for?
InterpreterSettingManagerdiscovers interpreters by reading each interpreter'sinterpreter-setting.json. Two helpers do this, and neither closes the stream it opens:The shared sink wraps the stream in an
InputStreamReaderand hands it togson.fromJson(...). Gson does not close a reader passed to it — the caller owns it — so the descriptor leaks on the normal path. There is nofinallyor try-with-resources either, so it also leaks when parsing throws, for example aJsonSyntaxExceptionfrom a malformed setting file.This is not limited to startup. After installing an interpreter through
POST /api/interpreter/install,InterpreterService.downloadInterpreter()callsrefreshInterpreterTemplates(), which re-runs the whole directory scan. Every install therefore leaks one descriptor per interpreter directory, and the leaks accumulate on a long-running server.This PR wraps each stream in a try-with-resources at the call site that opens it. Parsing and registration behaviour is unchanged. No signatures or access modifiers change.
What type of PR is it?
Bug Fix
Todos
[x] Close the stream opened in
registerInterpreterFromResource[x] Close the stream opened in
registerInterpreterFromPathWhat is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-6462
How should this be tested?
Tests run: 26, Failures: 0, Errors: 0, Skipped: 0, andzeppelin-serverbuilds.No tests accompany this change. Asserting that a stream is closed requires a seam in production code to inject a tracked stream, and an earlier revision of this PR added one — that is not worth carrying for a two-line fix, so it has been removed along with the tests that used it. The remaining change is the try-with-resources itself.
Screenshots (if appropriate)
N/A
Questions:
Does the license files need to update? No
Is there breaking changes for older versions? No
Does this needs documentation? No