Code review comment: If old version forward to new version, the request.catalog will be null. Will it report NEP?

Code before review:
public TMasterOpResult proxyExecute(TMasterOpRequest request) {
ctx.setCurrentCatalog(request.catalog);
ctx.setDatabase(request.db);
ctx.setQualifiedUser(request.user);
ctx.setGlobalStateMgr(GlobalStateMgr.getCurrentState());
ctx.getState().reset();
if (request.isSetResourceInfo()) {
ctx.getSessionVariable().setResourceGroup(request.getResourceInfo().getGroup());
}
if (request.isSetUser_ip()) {
ctx.setRemoteIP(request.getUser_ip());
}
if (request.isSetTime_zone()) {
ctx.getSessionVariable().setTimeZone(request.getTime_zone());
}
if (request.isSetStmt_id()) {
ctx.setForwardedStmtId(request.getStmt_id());
}
if (request.isSetSqlMode()) {
ctx.getSessionVariable().setSqlMode(request.sqlMode);
}
if (request.isSetEnableStrictMode()) {
ctx.getSessionVariable().setEnableInsertStrict(request.enableStrictMode);
}
if (request.isSetCurrent_user_ident()) {
UserIdentity currentUserIdentity = UserIdentity.fromThrift(request.getCurrent_user_ident());
ctx.setCurrentUserIdentity(currentUserIdentity);
}
if (request.isSetIsLastStmt()) {
ctx.setIsLastStmt(request.isIsLastStmt());
} else {
ctx.setIsLastStmt(true);
}
if (request.isSetQuery_options()) {
TQueryOptions queryOptions = request.getQuery_options();
if (queryOptions.isSetMem_limit()) {
ctx.getSessionVariable().setMaxExecMemByte(queryOptions.getMem_limit());
}
if (queryOptions.isSetQuery_timeout()) {
ctx.getSessionVariable().setQueryTimeoutS(queryOptions.getQuery_timeout());
}
if (queryOptions.isSetLoad_mem_limit()) {
ctx.getSessionVariable().setLoadMemLimit(queryOptions.getLoad_mem_limit());
}
if (queryOptions.isSetMax_scan_key_num()) {
ctx.getSessionVariable().setMaxScanKeyNum(queryOptions.getMax_scan_key_num());
}
if (queryOptions.isSetMax_pushdown_conditions_per_column()) {
ctx.getSessionVariable().setMaxPushdownConditionsPerColumn(
queryOptions.getMax_pushdown_conditions_per_column());
}
} else {
if (request.isSetExecMemLimit()) {
ctx.getSessionVariable().setMaxExecMemByte(request.getExecMemLimit());
}
if (request.isSetQueryTimeout()) {
ctx.getSessionVariable().setQueryTimeoutS(request.getQueryTimeout());
}
if (request.isSetLoadMemLimit()) {
ctx.getSessionVariable().setLoadMemLimit(request.loadMemLimit);
}
}
if (request.isSetQueryId()) {
ctx.setQueryId(UUIDUtil.fromTUniqueid(request.getQueryId()));
}
ctx.setThreadLocalInfo();
if (ctx.getCurrentUserIdentity() == null) {
TMasterOpResult result = new TMasterOpResult();
ctx.getState().setError(
"Missing current user identity. You need to upgrade this Frontend to the same version as Leader Frontend.");
result.setMaxJournalId(GlobalStateMgr.getCurrentState().getMaxJournalId());
result.setPacket(getResultPacket());
return result;
}
StmtExecutor executor = null;
try {
if (request.isSetModified_variables_sql()) {
LOG.info("Set session variables first: {}", request.modified_variables_sql);
new StmtExecutor(ctx, new OriginStatement(request.modified_variables_sql, 0), true).execute();
}
int idx = request.isSetStmtIdx() ? request.getStmtIdx() : 0;
executor = new StmtExecutor(ctx, new OriginStatement(request.getSql(), idx), true);
executor.execute();
} catch (IOException e) {
LOG.warn("Process one query failed because IOException: ", e);
ctx.getState().setError("StarRocks process failed: " + e.getMessage());
} catch (Throwable e) {
LOG.warn("Process one query failed because unknown reason: ", e);
ctx.getState().setError("Unexpected exception: " + e.getMessage());
}
TMasterOpResult result = new TMasterOpResult();
result.setMaxJournalId(GlobalStateMgr.getCurrentState().getMaxJournalId());
if (!ctx.getIsLastStmt()
&& ctx.getState().getStateType() != QueryState.MysqlStateType.ERR) {
ctx.getState().serverStatus |= MysqlServerStatusFlag.SERVER_MORE_RESULTS_EXISTS;
}
result.setPacket(getResultPacket());
result.setState(ctx.getState().getStateType().toString());
if (executor != null) {
if (executor.getProxyResultSet() != null) {
result.setResultSet(executor.getProxyResultSet().tothrift());
} else if (executor.getProxyResultBuffer() != null) {
result.setChannelBufferList(executor.getProxyResultBuffer());
}
}
return result;
}

Line under review: ctx.setCurrentCatalog(request.catalog);

Code after addressing the review:
public TMasterOpResult proxyExecute(TMasterOpRequest request) {
ctx.setCurrentCatalog(request.catalog);
if (ctx.getCurrentCatalog() == null) {
TMasterOpResult result = new TMasterOpResult();
ctx.getState().setError(
"Missing current catalog. You need to upgrade this Frontend to the same version as Leader Frontend.");
result.setMaxJournalId(GlobalStateMgr.getCurrentState().getMaxJournalId());
result.setPacket(getResultPacket());
return result;
}
ctx.setDatabase(request.db);
ctx.setQualifiedUser(request.user);
ctx.setGlobalStateMgr(GlobalStateMgr.getCurrentState());
ctx.getState().reset();
if (request.isSetResourceInfo()) {
ctx.getSessionVariable().setResourceGroup(request.getResourceInfo().getGroup());
}
if (request.isSetUser_ip()) {
ctx.setRemoteIP(request.getUser_ip());
}
if (request.isSetTime_zone()) {
ctx.getSessionVariable().setTimeZone(request.getTime_zone());
}
if (request.isSetStmt_id()) {
ctx.setForwardedStmtId(request.getStmt_id());
}
if (request.isSetSqlMode()) {
ctx.getSessionVariable().setSqlMode(request.sqlMode);
}
if (request.isSetEnableStrictMode()) {
ctx.getSessionVariable().setEnableInsertStrict(request.enableStrictMode);
}
if (request.isSetCurrent_user_ident()) {
UserIdentity currentUserIdentity = UserIdentity.fromThrift(request.getCurrent_user_ident());
ctx.setCurrentUserIdentity(currentUserIdentity);
}
if (request.isSetIsLastStmt()) {
ctx.setIsLastStmt(request.isIsLastStmt());
} else {
ctx.setIsLastStmt(true);
}
if (request.isSetQuery_options()) {
TQueryOptions queryOptions = request.getQuery_options();
if (queryOptions.isSetMem_limit()) {
ctx.getSessionVariable().setMaxExecMemByte(queryOptions.getMem_limit());
}
if (queryOptions.isSetQuery_timeout()) {
ctx.getSessionVariable().setQueryTimeoutS(queryOptions.getQuery_timeout());
}
if (queryOptions.isSetLoad_mem_limit()) {
ctx.getSessionVariable().setLoadMemLimit(queryOptions.getLoad_mem_limit());
}
if (queryOptions.isSetMax_scan_key_num()) {
ctx.getSessionVariable().setMaxScanKeyNum(queryOptions.getMax_scan_key_num());
}
if (queryOptions.isSetMax_pushdown_conditions_per_column()) {
ctx.getSessionVariable().setMaxPushdownConditionsPerColumn(
queryOptions.getMax_pushdown_conditions_per_column());
}
} else {
if (request.isSetExecMemLimit()) {
ctx.getSessionVariable().setMaxExecMemByte(request.getExecMemLimit());
}
if (request.isSetQueryTimeout()) {
ctx.getSessionVariable().setQueryTimeoutS(request.getQueryTimeout());
}
if (request.isSetLoadMemLimit()) {
ctx.getSessionVariable().setLoadMemLimit(request.loadMemLimit);
}
}
if (request.isSetQueryId()) {
ctx.setQueryId(UUIDUtil.fromTUniqueid(request.getQueryId()));
}
ctx.setThreadLocalInfo();
if (ctx.getCurrentUserIdentity() == null) {
TMasterOpResult result = new TMasterOpResult();
ctx.getState().setError(
"Missing current user identity. You need to upgrade this Frontend to the same version as Leader Frontend.");
result.setMaxJournalId(GlobalStateMgr.getCurrentState().getMaxJournalId());
result.setPacket(getResultPacket());
return result;
}
StmtExecutor executor = null;
try {
if (request.isSetModified_variables_sql()) {
LOG.info("Set session variables first: {}", request.modified_variables_sql);
new StmtExecutor(ctx, new OriginStatement(request.modified_variables_sql, 0), true).execute();
}
int idx = request.isSetStmtIdx() ? request.getStmtIdx() : 0;
executor = new StmtExecutor(ctx, new OriginStatement(request.getSql(), idx), true);
executor.execute();
} catch (IOException e) {
LOG.warn("Process one query failed because IOException: ", e);
ctx.getState().setError("StarRocks process failed: " + e.getMessage());
} catch (Throwable e) {
LOG.warn("Process one query failed because unknown reason: ", e);
ctx.getState().setError("Unexpected exception: " + e.getMessage());
}
TMasterOpResult result = new TMasterOpResult();
result.setMaxJournalId(GlobalStateMgr.getCurrentState().getMaxJournalId());
if (!ctx.getIsLastStmt()
&& ctx.getState().getStateType() != QueryState.MysqlStateType.ERR) {
ctx.getState().serverStatus |= MysqlServerStatusFlag.SERVER_MORE_RESULTS_EXISTS;
}
result.setPacket(getResultPacket());
result.setState(ctx.getState().getStateType().toString());
if (executor != null) {
if (executor.getProxyResultSet() != null) {
result.setResultSet(executor.getProxyResultSet().tothrift());
} else if (executor.getProxyResultBuffer() != null) {
result.setChannelBufferList(executor.getProxyResultBuffer());
}
}
return result;
}