← Back to Pull requests

[ZEPPELIN-6462] Close interpreter-setting.json streams with try-with-resources #5355

Closed
unknown closed this pull request without merging on Aug 06, 2026 02:02 UTC
View on GitHub
unknown unknown commented on Jul 28, 2026 04:06 UTC
Author

What is this PR for?

InterpreterSettingManager discovers interpreters by reading each interpreter's interpreter-setting.json. Two helpers do this, and neither closes the stream it opens:

// registerInterpreterFromResource
getInterpreterListFromJson(url.openStream());

// registerInterpreterFromPath
getInterpreterListFromJson(new FileInputStream(interpreterJsonPath.toFile()));

The shared sink wraps the stream in an InputStreamReader and hands it to gson.fromJson(...). Gson does not close a reader passed to it — the caller owns it — so the descriptor leaks on the normal path. There is no finally or try-with-resources either, so it also leaks when parsing throws, for example a JsonSyntaxException from a malformed setting file.

This is not limited to startup. After installing an interpreter through POST /api/interpreter/install, InterpreterService.downloadInterpreter() calls refreshInterpreterTemplates(), 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 registerInterpreterFromPath

What is the Jira issue?


https://issues.apache.org/jira/browse/ZEPPELIN-6462

How should this be tested?

./mvnw package -pl zeppelin-server --am \
  -Dtest='InterpreterSettingManagerTest,InterpreterFactoryTest,InterpreterSettingTest' \
  -DfailIfNoTests=false

Tests run: 26, Failures: 0, Errors: 0, Skipped: 0, and zeppelin-server builds.

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

Diff: 294 lines (+220 / -74) across 3 files Reviewer: Reamer Review duration: 12836m
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
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.9% (MEDIUM) · Higher = larger blast radius
39.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17.3% · Safe to merge
17.3%