diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java index 8bdc88a9c2237f..c2d50460ea4954 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java @@ -62,6 +62,7 @@ import java.net.URI; import java.util.Enumeration; import java.util.List; +import java.util.Optional; import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -293,8 +294,17 @@ private Object executeWithoutPassword(HttpServletRequest request, return new RestBaseResult(e.getMessage()); } } else { - long tableId = ((OlapTable) ((Database) Env.getCurrentEnv().getCurrentCatalog().getDb(dbName) - .get()).getTable(tableName).get()).getId(); + Optional database = Env.getCurrentEnv().getCurrentCatalog().getDb(dbName); + if (!database.isPresent()) { + return new RestBaseResult("Database not founded."); + } + + Optional olapTable = ((Database) database.get()).getTable(tableName); + if (!olapTable.isPresent()) { + return new RestBaseResult("OlapTable not founded."); + } + + long tableId = ((OlapTable) olapTable.get()).getId(); redirectAddr = selectRedirectBackend(request, groupCommit, tableId); }