This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch branch-0.12
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/branch-0.12 by this push:
new 1e99090a7c [ZEPPELIN-6104] Fix NPE when some MongoDB Interpreter
configs are missing
1e99090a7c is described below
commit 1e99090a7c198916421f798ebb84f20fc4ad5d46
Author: SeungYoung Oh <[email protected]>
AuthorDate: Sun Sep 29 16:45:05 2024 +0900
[ZEPPELIN-6104] Fix NPE when some MongoDB Interpreter configs are missing
### What is this PR for?
This PR avoids an NPE when some MongoDB Interpreter configs are missing by
replacing them with empty strings.
If certain MongoDB Interpreter configs, such as the username, password, or
authenticationDatabase, are not entered, it throws an NPE. MongoDB allows
logins without authentication when authentication is not enabled, so these
configs are not always required. Since authentication is off by default in
MongoDB, and these configs are also empty by default in Apache Zeppelin, this
could be confusing for users.
And as you can see in
[shell_extension.js](https://github.com/apache/zeppelin/blob/ac48cc2db1b55257230cae2c382961da2a9cf80d/mongodb/src/main/resources/shell_extension.js#L115),
the MongoDB interpreter appears to be designed to skip authorization when the
username is null.
### What type of PR is it?
Improvement
### Todos
### What is the Jira issue?
[ZEPPELIN-6104]
### How should this be tested?
* run the MongoDB notebook
### Questions:
* Does the license files need to update? N
* Is there breaking changes for older versions? N
* Does this needs documentation? N
Closes #4844 from seung-00/ZEPPELIN-6104.
Signed-off-by: Cheng Pan <[email protected]>
(cherry picked from commit 9a28960c31c38975783a3f64ed801adef61c0696)
Signed-off-by: Cheng Pan <[email protected]>
---
.../main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git
a/mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
b/mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
index 990909a86d..54c121fcdf 100644
--- a/mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
+++ b/mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
@@ -197,8 +197,8 @@ public class MongoDbInterpreter extends Interpreter {
private void prepareShellExtension(){
shellExtension = shellExtension.replace("TABLE_LIMIT_PLACEHOLDER",
getProperty("mongo.shell.command.table.limit"))
.replace("TARGET_DB_PLACEHOLDER",
getProperty("mongo.server.database"))
- .replace("USER_NAME_PLACEHOLDER",
getProperty("mongo.server.username"))
- .replace("PASSWORD_PLACEHOLDER",
getProperty("mongo.server.password"))
- .replace("AUTH_DB_PLACEHOLDER",
getProperty("mongo.server.authenticationDatabase"));
+ .replace("USER_NAME_PLACEHOLDER",
getProperty("mongo.server.username", ""))
+ .replace("PASSWORD_PLACEHOLDER",
getProperty("mongo.server.password", ""))
+ .replace("AUTH_DB_PLACEHOLDER",
getProperty("mongo.server.authenticationDatabase", ""));
}
-}
\ No newline at end of file
+}