Reamer commented on a change in pull request #3718: [ZEPPELIN-4727] Fix HDFS 
Credentials storage 
URL: https://github.com/apache/zeppelin/pull/3718#discussion_r406688577
 
 

 ##########
 File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/rest/CredentialRestApi.java
 ##########
 @@ -75,66 +73,83 @@ public Response putCredentials(String message) throws 
IOException, IllegalArgume
     if (Strings.isNullOrEmpty(entity)
         || Strings.isNullOrEmpty(username)
         || Strings.isNullOrEmpty(password)) {
-      return new JsonResponse(Status.BAD_REQUEST).build();
+      return new JsonResponse<>(Status.BAD_REQUEST).build();
     }
 
     String user = authenticationService.getPrincipal();
-    logger.info("Update credentials for user {} entity {}", user, entity);
-    UserCredentials uc = credentials.getUserCredentials(user);
-    uc.putUsernamePassword(entity, new UsernamePassword(username, password));
-    credentials.putUserCredentials(user, uc);
-    return new JsonResponse(Status.OK).build();
+    LOGGER.info("Update credentials for user {} entity {}", user, entity);
+    UserCredentials uc;
+    try {
+      uc = credentials.getUserCredentials(user);
+      uc.putUsernamePassword(entity, new UsernamePassword(username, password));
+      credentials.putUserCredentials(user, uc);
+      return new JsonResponse<>(Status.OK).build();
+    } catch (IOException e) {
+      LOGGER.error(e.getMessage(), e);
+      return new JsonResponse<>(Status.INTERNAL_SERVER_ERROR).build();
+    }
   }
 
   /**
    * Get User Credentials list REST API.
    *
    * @return JSON with status.OK
-   * @throws IllegalArgumentException
    */
   @GET
-  public Response getCredentials() throws IllegalArgumentException {
+  public Response getCredentials() {
     String user = authenticationService.getPrincipal();
-    logger.info("getCredentials credentials for user {} ", user);
-    UserCredentials uc = credentials.getUserCredentials(user);
-    return new JsonResponse<>(Status.OK, uc).build();
+    LOGGER.info("getCredentials credentials for user {} ", user);
 
 Review comment:
   Changed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to