This is an automated email from the ASF dual-hosted git repository.

zjffdu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new 704f2b9  [ZEPPELIN-5192]: Don't try to decrypt a non-existent 
credentials file
704f2b9 is described below

commit 704f2b9d31678e5561be47e6466eb23bd0b5e9e7
Author: Niels Grewe <[email protected]>
AuthorDate: Sat Feb 27 00:03:53 2021 +0100

    [ZEPPELIN-5192]: Don't try to decrypt a non-existent credentials file
    
    ### What is this PR for?
    
    This is a very simple fix for the issue described in 
[ZEPPELIN-5192](https://issues.apache.org/jira/browse/ZEPPELIN-5192): Zeppelin 
will currently fail to start if a credentials encryption key is configured but 
no `credentials.json` file exists currently. This is due to an NPE inside the 
decryption code path. The fix is to only attempt the decryption if the file 
could be loaded.
    
    ### What type of PR is it?
    
    [Bug Fix]
    
    ### What is the Jira issue?
    
    * [ZEPPELIN-5192](https://issues.apache.org/jira/browse/ZEPPELIN-5192)
    
    ### How should this be tested?
    
    Booting a fresh Zeppelin server with ZEPPELIN_CREDENTIALS_ENCRYPT_KEY set 
is sufficient to reproduce the issue and validate the fix.
    
    Author: Niels Grewe <[email protected]>
    
    Closes #4062 from ngrewe/bugfix/ZEPPELIN-5192 and squashes the following 
commits:
    
    6dd974358 [Niels Grewe] fix(ZEPPELIN-5192): Don't try to decrypt a 
non-existent credentials file
---
 .../src/main/java/org/apache/zeppelin/user/Credentials.java             | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Credentials.java 
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Credentials.java
index 867d79e..df69853 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Credentials.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Credentials.java
@@ -137,7 +137,7 @@ public class Credentials {
   private void loadFromFile() throws IOException {
     try {
       String json = storage.loadCredentials();
-      if (encryptor != null) {
+      if (json != null && encryptor != null) {
         json = encryptor.decrypt(json);
       }
 

Reply via email to