@Override
    public void commit() throws SQLException {
        for (TransactionHook each : transactionHooks) {
            each.beforeCommit(connection.getCachedConnections().values(), getTransactionContext(), ProxyContext.getInstance().getContextManager().getComputeNodeInstanceContext().getLockContext());
        }
        if (connection.getConnectionSession().getTransactionStatus().isInTransaction()) {
            try {
                if (TransactionType.LOCAL == TransactionUtils.getTransactionType(getTransactionContext()) || null == distributionTransactionManager) {
                    localTransactionManager.commit();
                } else {
                    distributionTransactionManager.commit(getTransactionContext().isExceptionOccur());
                }
            } finally {
                for (TransactionHook each : transactionHooks) {
                    each.afterCommit(connection.getCachedConnections().values(),
                            getTransactionContext(), ProxyContext.getInstance().getContextManager().getComputeNodeInstanceContext().getLockContext());
                }
                for (Connection each : connection.getCachedConnections().values()) {
                    ConnectionSavepointManager.getInstance().transactionFinished(each);
                }
                connection.getConnectionSession().getTransactionStatus().setInTransaction(false);
                connection.getConnectionSession().getConnectionContext().close();
            }
        }
    }
@Test
    void assertCommitForDistributedTransaction() throws SQLException {
        ContextManager contextManager = mockContextManager(TransactionType.XA);
        when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
        newBackendTransactionManager(TransactionType.XA, true);
        backendTransactionManager.commit();
        verify(transactionStatus).setInTransaction(false);
        verify(distributionTransactionManager).commit(false);
    }