protected void waitTransactionDataClear() throws InterruptedException {
        this.cleanExpireTransactionData();
        long waitMs = Math.max(this.maxTransactionDataExpireTime.get() - System.currentTimeMillis(), 0);
        waitMs = Math.min(waitMs, ConfigurationManager.getProxyConfig().getTransactionDataMaxWaitClearMillis());

        if (waitMs > 0) {
            TimeUnit.MILLISECONDS.sleep(waitMs);
        }
    }
@Test
    public void testWaitTransactionDataClear() throws InterruptedException {
        // Skip this test case on Mac as it's not stable enough.
        Assume.assumeFalse(MixAll.isMac());
        String txId = MessageClientIDSetter.createUniqID();
        this.transactionDataManager.addTransactionData(PRODUCER_GROUP, txId,
            createTransactionData(txId, System.currentTimeMillis(), Duration.ofMillis(100).toMillis()));
        this.transactionDataManager.addTransactionData(PRODUCER_GROUP, txId,
            createTransactionData(txId, System.currentTimeMillis(), Duration.ofMillis(500).toMillis()));

        this.transactionDataManager.addTransactionData(PRODUCER_GROUP, MessageClientIDSetter.createUniqID(),
            createTransactionData(txId, System.currentTimeMillis(), Duration.ofMillis(1000).toMillis()));

        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        this.transactionDataManager.waitTransactionDataClear();
        stopWatch.stop();
        assertTrue(Math.abs(stopWatch.getTime() - 1000) <= 50);
    }