@VisibleForTesting
    public static TFeLocksRes listLocks(TFeLocksReq request, boolean authenticate) throws TException {
        TAuthInfo auth = request.getAuth_info();
        UserIdentity currentUser;
        if (auth.isSetCurrent_user_ident()) {
            currentUser = UserIdentity.fromThrift(auth.getCurrent_user_ident());
        } else {
            currentUser = UserIdentity.createAnalyzedUserIdentWithIp(auth.getUser(), auth.getUser_ip());
        }

        // authorize
        try {
            if (authenticate) {
                Authorizer.checkSystemAction(currentUser, null, PrivilegeType.OPERATE);
            }
        } catch (AccessDeniedException e) {
            throw new TException(e.getMessage(), e);
        }

        TFeLocksRes response = new TFeLocksRes();
        if (Config.lock_manager_enabled) {
            long currentTime = System.currentTimeMillis();
            LockManager lockManager = GlobalStateMgr.getCurrentState().getLockManager();
            List<LockInfo> lockInfos = lockManager.dumpLockManager();

            for (LockInfo lockInfo : lockInfos) {
                for (LockHolder owner : lockInfo.getOwners()) {
                    TFeLocksItem lockItem = new TFeLocksItem();

                    lockItem.setLock_type("");
                    lockItem.setLock_object(String.valueOf(lockInfo.getRid()));
                    lockItem.setLock_mode(owner.getLockType().toString());
                    lockItem.setStart_time(owner.getLocker().getLockRequestTimeMs());
                    lockItem.setHold_time_ms(currentTime - owner.getLockAcquireTimeMs());

                    JsonObject ownerInfo = new JsonObject();
                    ownerInfo.addProperty("threadId", owner.getLocker().getLockerThread().getId());
                    ownerInfo.addProperty("threadName", owner.getLocker().getLockerThread().getName());
                    lockItem.setThread_info(ownerInfo.toString());

                    Collection<Thread> threads = lockInfo.getWaiters().stream().map(LockHolder::getLocker)
                            .map(Locker::getLockerThread).collect(Collectors.toList());
                    lockItem.setWaiter_list(LockChecker.getLockWaiterInfoJsonArray(threads).toString());

                    response.addToItems(lockItem);
                }
            }
        } else {
            Collection<Database> dbs = GlobalStateMgr.getCurrentState().getLocalMetastore().getFullNameToDb().values();
            for (Database db : CollectionUtils.emptyIfNull(dbs)) {
                TFeLocksItem item = resolveLockInfo(db);
                response.addToItems(item);
            }
        }
        return response;
    }
@Test
    public void testListLocks() throws TException {
        TFeLocksReq req = new TFeLocksReq();
        TAuthInfo auth = new TAuthInfo();
        auth.setUser("root");
        auth.setUser_ip("127.0.0.1");
        req.setAuth_info(auth);

        var res = SysFeLocks.listLocks(req, false);
        assertTrue(StringUtils.isNotEmpty(res.toString()));
    }