justinmclean opened a new issue, #10268:
URL: https://github.com/apache/gravitino/issues/10268

   ### What would you like to be improved?
   
   ConfigServlet#doGet catches IllegalStateException, IOException, and generic 
Exception but only logs them. It does not set an error status or return an 
error payload. If res.getWriter() or response writing fails (for example due to 
client disconnect or output stream failure), the endpoint can fail silently, 
leaving clients with an aborted/partial response and no explicit server-side 
HTTP failure signal.
   
   ### How should we improve?
   
   In ConfigServlet#doGet, when any exception occurs during response 
generation, set HttpServletResponse.SC_INTERNAL_SERVER_ERROR and return a small 
JSON error body (or at minimum set the status). Keep logging with exception 
context.
   
   Here's a unit test to help:
   ```
     @Test
     public void testDoGetShouldSetInternalServerErrorWhenGetWriterFails() 
throws Exception {
       ConfigServlet configServlet = new ConfigServlet(new ServerConfig());
       HttpServletResponse response = mock(HttpServletResponse.class);
       when(response.getWriter()).thenThrow(new IOException("broken output 
stream"));
   
       configServlet.doGet(null, response);
   
       verify(response).setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
     }
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to