[ZEPPELIN-6232] Prevent duplicate interpreter repositories on server restart #4981
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?
OVERVIEW
This PR fixes a bug where modifying a default interpreter repository (e.g., 'central') and restarting the Zeppelin server would result in a duplicate repository entry instead of an overwrite.
For example, if a user added a new
central
repository to interpreter, it just replace the default central repository as we expected.but, when restart, the UI would incorrectly display two
central
repositories: the user-modified one and the default one.This happens because
interpreter.json
file have twocentral
in interpreterRepositories field.ROOT CAUSE
The issue was in the repository loading logic within InterpreterSettingManager. When loading settings from
interpreter.json
on startup, the code checked for the existence of a repository usingList.contains(repo)
.This check failed because the default repository object and the user-modified repository 'object' were not identical (e.g., one had authentication details, the other did not), even though their IDs were the same ('central'). This led to the manager incorrectly treating the user's repository as a new entry and adding it, causing the duplication.
MODIFICATION
The repository loading logic in InterpreterSettingManager's loadFromFile() has been modified to correctly handle user-defined repositories.
Instead of using
List.contains()
, the new logic now iterates through the existing list of repositories and explicitly checks for matching IDs.This ensures that user modifications to default repositories are correctly persisted across server restarts and prevents duplicate entries.
dependencyResolver.getRepos()
as before, I change this to use justinterpreterRepositories
in InterpreterSettingManager.interpreterRepositories
already initialized with dependencyResolver.getRepos() on initialize stage, and so far there is no side effect to change this. It is more intuitive to iterate interpreterRepositories to change interpreterRepositories.SIDE EFFECT
When user overwrite the default repo, like
central
, orlocal
, they are still default repos with different info.(Only when
interpreter.json
has this changed info. when this file removed, then original default repo show up.)So I guess there's not so much things to be affected by this change.
What type of PR is it?
Bug Fix
Todos
What is the Jira issue?
[ZEPPELIN-6232]
How should this be tested?
A new unit test,
testShouldNotDuplicateRepoOnReloadWhenDefaultRepoIsModified
, has been added toInterpreterSettingManagerTest.java
.This test simulates the exact scenario of the bug:
If you want to test manually:
interpreter
menu, you can add a newcentral
repo, and it replace the default one immediately. (Works either current and fixed version)central
repo. (current version)central
repo, which is user-defined. (fixed version)interpreter.json
in /conf.Screenshots (if appropriate)
Questions: