Reamer commented on code in PR #5022:
URL: https://github.com/apache/zeppelin/pull/5022#discussion_r2278300481


##########
zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java:
##########
@@ -1187,4 +1189,72 @@ void testRunWithServerRestart() throws Exception {
       }
     }
   }
+
+  @Test
+  void testGetJobList_whenJobManagerDisabled() throws IOException {
+    boolean originalFlag = disableJobManagerAndBackupFlag();
+    String expectedErrorMessage = "Job Manager is disabled in the current 
configuration.";
+    CloseableHttpResponse response = null;
+
+    try {
+      response = httpGet("/notebook/jobmanager/");
+      assertEquals(Response.Status.FORBIDDEN.getStatusCode(),
+          response.getStatusLine().getStatusCode(),
+          "Response status should be 403 Forbidden");
+
+      String jsonResponse = EntityUtils.toString(response.getEntity(), 
StandardCharsets.UTF_8);
+      Map<String, Object> parsedResponse = gson.fromJson(jsonResponse,
+          new TypeToken<Map<String, Object>>() {}.getType());
+
+      assertEquals("FORBIDDEN", parsedResponse.get("status"));
+      assertEquals(expectedErrorMessage, parsedResponse.get("message"));
+
+    } finally {
+      if (response != null) {
+        response.close();
+      }
+      restoreJobManagerFlag(originalFlag);
+    }
+  }
+
+  @Test
+  void testGetUpdatedJobList_whenJobManagerDisabled() throws IOException {
+    boolean originalFlag = disableJobManagerAndBackupFlag();
+    String expectedErrorMessage = "Job Manager is disabled in the current 
configuration.";
+    CloseableHttpResponse response = null;
+
+    try {

Review Comment:
   Please use the try-with-resources pattern, which is more elegant.
   
https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html



##########
zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java:
##########
@@ -1932,6 +1943,11 @@ public void 
onSuccess(List<JobManagerService.NoteJobInfo> notesJobInfo,
       
connectionManager.broadcast(JobManagerServiceType.JOB_MANAGER_PAGE.getKey(),
           new Message(OP.LIST_UPDATE_NOTE_JOBS).put("noteRunningJobs", 
response));
     }
+
+    @Override
+    public void onFailure(Exception ex, ServiceContext context) {
+      LOGGER.debug(ex.getMessage());

Review Comment:
   The parent method should still be called so that other exceptions continue 
to be logged and handled.
   ```suggestion
         if (ex instanceof JobManagerForbiddenException) {
             LOGGER.debug(ex.getMessage());
         } else {
             super.onFailure(ex, context);
         }
   ```



-- 
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.

To unsubscribe, e-mail: reviews-unsubscr...@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to