World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#2178] Improvement: Add missing exception handling in doGet in ConfigServlet.java (#2214)
Chun-Hung Tsenga51ae344c2f3
diff --git a/server/src/main/java/com/datastrato/gravitino/server/web/ConfigServlet.java b/server/src/main/java/com/datastrato/gravitino/server/web/ConfigServlet.javaindex 0b2517e99e..e7a23b0f62 100644--- a/server/src/main/java/com/datastrato/gravitino/server/web/ConfigServlet.java+++ b/server/src/main/java/com/datastrato/gravitino/server/web/ConfigServlet.java@@ -15,8 +15,8 @@ import com.google.common.collect.ImmutableSet;import com.google.common.collect.Maps;import java.io.IOException;import java.io.PrintWriter;+import java.io.UnsupportedEncodingException;import java.util.Map;-import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;@@ -46,11 +46,19 @@ public class ConfigServlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse res)- throws ServletException, IOException {+ throws UnsupportedEncodingException, IllegalStateException, IOException {try (PrintWriter writer = res.getWriter()) {ObjectMapper objectMapper = JsonUtils.objectMapper();res.setContentType("application/json;charset=utf-8");writer.write(objectMapper.writeValueAsString(configs));+ } catch (UnsupportedEncodingException exception) {+ throw new RuntimeException("Failed to use returned character encoding", exception);+ } catch (IllegalStateException exception) {+ throw new RuntimeException("Wrong usage of getWriter()", exception);+ } catch (IOException exception) {+ throw new RuntimeException("Failed to perform IO", exception);+ } catch (Exception e) {+ throw new RuntimeException(e);}}}