[fix](multi-catalog)switching catalogs after dropping will get NPE. (#16067)

Issue Number: close #16066
This commit is contained in:
qiye
2023-01-19 15:13:21 +08:00
committed by GitHub
parent b9f1e4a17f
commit 47aa53fa72

View File

@ -4357,7 +4357,10 @@ public class Env {
String currentDB = ctx.getDatabase();
if (StringUtils.isNotEmpty(currentDB)) {
catalogMgr.addLastDBOfCatalog(ctx.getCurrentCatalog().getName(), currentDB);
// When dropped the current catalog in current context, the current catalog will be null.
if (ctx.getCurrentCatalog() != null) {
catalogMgr.addLastDBOfCatalog(ctx.getCurrentCatalog().getName(), currentDB);
}
}
ctx.changeDefaultCatalog(catalogName);
String lastDb = catalogMgr.getLastDB(catalogName);