[ZEPPELIN-6474] Handle NumberFormatException when parsing MongoDB interpreter numeric properties - #5356
Open
sylee6529 wants to merge 1 commit into
Open
Conversation
…erpreter numeric properties MongoDbInterpreter.open() parsed mongo.shell.command.timeout and mongo.interpreter.concurrency.max outside any try/catch, so an empty, missing, or non-numeric value surfaced as a raw NumberFormatException that never named the offending property. Users saw only a stack trace and could not tell which setting to fix. Wrap each parse and re-throw it as an InterpreterException that names the property and its invalid value, keeping the original exception as the cause. open() now declares throws InterpreterException, which the base Interpreter.open() already declares. Scope is limited to these two parses: no range validation and no silent fallback to default values. An invalid configuration still fails, it just fails understandably.
jongyoul
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR for?
MongoDbInterpreter.open()parses two numeric properties,mongo.shell.command.timeoutandmongo.interpreter.concurrency.max, withLong.parseLong()/Integer.parseInt()outside anytry/catch— the existing try-with-resources in that method covers only theScannerthat loads the shell extension. When either value is empty, missing, or non-numeric, a rawNumberFormatExceptionescapesopen().Because
open()is triggered lazily by the first paragraph run, this lands in the notebook paragraph as a bare stack trace that never names the property at fault. The MongoDB interpreter has several numeric properties, so the only way to tell which one failed today is to read the line number off the trace and open the source — which is not something a Zeppelin user should have to do.Reproduced on JDK 11: an empty value yields
NumberFormatException: For input string: "", a non-numeric value yieldsFor input string: "60s", and a missing property yields a message of justnull. One note on that last case — the issue describes it asCannot parse null string, but that wording comes from newer JDKs. On the JDK 11 this project builds with,Long.parseLong(null)throwsNumberFormatException("null"), so the message carries even less information than the issue suggests.What does this PR do?
NumberFormatExceptionas anInterpreterExceptionthat names the property and its invalid value, keeping the original exception as the cause:throws InterpreterExceptionto theopen()override. The baseInterpreter.open()already declares it, so no caller contract changes — at runtime the call goes throughLazyOpenInterpreter.open(), which already declares it too, and the only direct caller was the test.Per the issue, the scope is deliberately narrow: no range validation, no silent fallback to default values, no unrelated changes. An invalid configuration still fails exactly as before; it just fails understandably.
What type of PR is it?
Improvement
What is the Jira issue?
How should this be tested?
./mvnw test -pl mongodbMongoDbInterpreterTest, covering both properties across the three failure modes named in the issue: non-numeric and missing formongo.shell.command.timeout, empty and missing formongo.interpreter.concurrency.max. Each asserts that anInterpreterExceptionis thrown, that its message names the offending property, and that the originalNumberFormatExceptionis preserved as the cause. The two remaining combinations exercise the identical catch block, so they were left out rather than duplicated.MongoDbInterpreterTest.init()now declaresthrows InterpreterException, since it callsopen()on the concrete type.MongoDbInterpreterand re-ran the suite: exactly the four new tests fail withexpected: <InterpreterException> but was: <NumberFormatException>, while the two pre-existing tests still pass. With the change applied, all six pass.Questions: