Java Code Examples for javax.transaction.Status#STATUS_PREPARED

The following examples show how to use javax.transaction.Status#STATUS_PREPARED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransactionContext.java    From quarkus with Apache License 2.0 6 votes vote down vote up
/**
 * The transaction scoped context is active when a transaction is active.
 */
@Override
public boolean isActive() {
    Transaction transaction = getCurrentTransaction();
    if (transaction == null) {
        return false;
    }

    try {
        int currentStatus = transaction.getStatus();
        return currentStatus == Status.STATUS_ACTIVE ||
                currentStatus == Status.STATUS_MARKED_ROLLBACK ||
                currentStatus == Status.STATUS_PREPARED ||
                currentStatus == Status.STATUS_UNKNOWN ||
                currentStatus == Status.STATUS_PREPARING ||
                currentStatus == Status.STATUS_COMMITTING ||
                currentStatus == Status.STATUS_ROLLING_BACK;
    } catch (SystemException e) {
        throw new RuntimeException("Error getting the status of the current transaction", e);
    }
}
 
Example 2
Source File: JtaTransaction.java    From cdi with Apache License 2.0 6 votes vote down vote up
private String statusToString(int status) {
    switch (status) {
        case Status.STATUS_ACTIVE:
            return "Active";
        case Status.STATUS_COMMITTED:
            return "Committed";
        case Status.STATUS_COMMITTING:
            return "Commiting";
        case Status.STATUS_MARKED_ROLLBACK:
            return "Marked for rollback";
        case Status.STATUS_NO_TRANSACTION:
            return "No transaction";
        case Status.STATUS_PREPARED:
            return "Prepared";
        case Status.STATUS_PREPARING:
            return "Preparing";
        case Status.STATUS_ROLLEDBACK:
            return "Rolled back";
        case Status.STATUS_ROLLING_BACK:
            return "Rolling back";
        case Status.STATUS_UNKNOWN:
            return "Unknown";
        default:
            return null;
    }
}
 
Example 3
Source File: TransactionScopedEntityManager.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private boolean isInTransaction() {
    try {
        switch (transactionManager.getStatus()) {
            case Status.STATUS_ACTIVE:
            case Status.STATUS_COMMITTING:
            case Status.STATUS_MARKED_ROLLBACK:
            case Status.STATUS_PREPARED:
            case Status.STATUS_PREPARING:
                return true;
            default:
                return false;
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 4
Source File: TracingTransactionInterceptor.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * @param txStatus
 * @return String
 */
private static final String toString(int txStatus) {
    switch (txStatus) {
        case Status.STATUS_ACTIVE: return "STATUS_ACTIVE";
        case Status.STATUS_COMMITTED: return "STATUS_COMMITTED";  
        case Status.STATUS_COMMITTING: return "STATUS_COMMITTING";
        case Status.STATUS_MARKED_ROLLBACK: return "STATUS_MARKED_ROLLBACK";
        case Status.STATUS_NO_TRANSACTION: return "STATUS_NO_TRANSACTION";
        case Status.STATUS_PREPARED: return "STATUS_PREPARED";
        case Status.STATUS_PREPARING: return "STATUS_PREPARING";
        case Status.STATUS_ROLLEDBACK: return "STATUS_ROLLEDBACK";
        case Status.STATUS_ROLLING_BACK: return "STATUS_ROLLING_BACK";
        case Status.STATUS_UNKNOWN: return "STATUS_UNKNOWN";
        default: return "unknown status: " + txStatus;
    }
}
 
Example 5
Source File: TransactionRecoveryImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void recoverParticipant(Transaction transaction)
		throws CommitRequiredException, RollbackRequiredException, SystemException {

	TransactionImpl transactionImpl = (TransactionImpl) transaction;
	switch (transaction.getTransactionStatus()) {
	case Status.STATUS_PREPARED:
	case Status.STATUS_COMMITTING:
		break;
	case Status.STATUS_COMMITTED:
	case Status.STATUS_ROLLEDBACK:
		break;
	case Status.STATUS_ACTIVE:
	case Status.STATUS_MARKED_ROLLBACK:
	case Status.STATUS_PREPARING:
	case Status.STATUS_UNKNOWN:
	case Status.STATUS_ROLLING_BACK:
	default:
		transactionImpl.recoveryRollback();
		transactionImpl.forgetQuietly();
	}
}
 
Example 6
Source File: TransactionRecoveryImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void recoverCoordinator(Transaction transaction)
		throws CommitRequiredException, RollbackRequiredException, SystemException {

	switch (transaction.getTransactionStatus()) {
	case Status.STATUS_ACTIVE:
	case Status.STATUS_MARKED_ROLLBACK:
	case Status.STATUS_PREPARING:
	case Status.STATUS_ROLLING_BACK:
	case Status.STATUS_UNKNOWN:
		transaction.recoveryRollback();
		transaction.forgetQuietly();
		break;
	case Status.STATUS_PREPARED:
	case Status.STATUS_COMMITTING:
		transaction.recoveryCommit();
		transaction.forgetQuietly();
		break;
	case Status.STATUS_COMMITTED:
	case Status.STATUS_ROLLEDBACK:
		transaction.forgetQuietly();
		break;
	default:
		logger.debug("Current transaction has already been completed.");
	}
}
 
Example 7
Source File: ActiveMQRAManagedConnection.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public void checkTransactionActive() throws JMSException {
   // don't bother looking at the transaction if there's an active XID
   if (!inManagedTx && tm != null) {
      try {
         Transaction tx = tm.getTransaction();
         if (tx != null) {
            int status = tx.getStatus();
            // Only allow states that will actually succeed
            if (status != Status.STATUS_ACTIVE && status != Status.STATUS_PREPARING && status != Status.STATUS_PREPARED && status != Status.STATUS_COMMITTING) {
               throw new javax.jms.IllegalStateException("Transaction " + tx + " not active");
            }
         }
      } catch (SystemException e) {
         JMSException jmsE = new javax.jms.IllegalStateException("Unexpected exception on the Transaction ManagerTransaction");
         jmsE.initCause(e);
         throw jmsE;
      }
   }
}
 
Example 8
Source File: TransactionContext.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isActive() {
    try {
        final int status = transactionManager.getTransaction().getStatus();
        return status == Status.STATUS_ACTIVE || status == Status.STATUS_MARKED_ROLLBACK
            || status == Status.STATUS_PREPARED || status == Status.STATUS_PREPARING
            || status == Status.STATUS_COMMITTING || status == Status.STATUS_ROLLING_BACK
            || status == Status.STATUS_UNKNOWN;
    } catch (final Throwable e) {
        return false;
    }
}
 
Example 9
Source File: TransactionImpl.java    From clearpool with GNU General Public License v3.0 5 votes vote down vote up
private boolean tryPrepared() {
  this.status = Status.STATUS_PREPARING;
  boolean preparedSuccess = true;
  for (ResourceCarry carry : this.resList) {
    try {
      int result = carry.xaRes.prepare(carry.xid);
      preparedSuccess &= result == XAResource.XA_OK;
    } catch (XAException e) {
      LOGGER.error("prepare XA error(code=" + e.errorCode + "): ", e);
      preparedSuccess = false;
    }
  }
  this.status = Status.STATUS_PREPARED;
  return preparedSuccess;
}
 
Example 10
Source File: JackRabbitUserTransaction.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @see javax.transaction.UserTransaction#commit
 */
@Override
public void commit() throws IllegalStateException, RollbackException, SecurityException, SystemException {

    if (status != Status.STATUS_ACTIVE) {
        throw new IllegalStateException("Transaction not active");
    }

    try {
        xares.end(xid, XAResource.TMSUCCESS);

        status = Status.STATUS_PREPARING;
        xares.prepare(xid);
        status = Status.STATUS_PREPARED;

        status = Status.STATUS_COMMITTING;
        xares.commit(xid, false);
        status = Status.STATUS_COMMITTED;

    } catch (XAException e) {

        if (e.errorCode >= XAException.XA_RBBASE && e.errorCode <= XAException.XA_RBEND) {
            RollbackException rollbackException = new RollbackException(e.toString());
            rollbackException.initCause(e);
            throw rollbackException;
        }

        final SystemException systemException = new SystemException("Unable to commit transaction: " + "XA_ERR="
                + e.errorCode);
        systemException.initCause(e);
        throw systemException;
    }
}
 
Example 11
Source File: TransactionContext.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isActive() {
    try {
        final int status = transactionManager.getTransaction().getStatus();
        return status == Status.STATUS_ACTIVE || status == Status.STATUS_MARKED_ROLLBACK
                || status == Status.STATUS_PREPARED || status == Status.STATUS_PREPARING
                || status == Status.STATUS_COMMITTING || status == Status.STATUS_ROLLING_BACK
                || status == Status.STATUS_UNKNOWN;
    } catch (final Throwable e) {
        return false;
    }
}
 
Example 12
Source File: CompensableTransactionImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 5 votes vote down vote up
public synchronized void recover() throws SystemException {
	if (this.transactionStatus == Status.STATUS_PREPARED //
			|| this.transactionStatus == Status.STATUS_COMMITTING) {
		this.recoverNativeResource(true);
		this.recoverRemoteResource(true);
	} else if (this.transactionStatus == Status.STATUS_PREPARING //
			|| this.transactionStatus == Status.STATUS_ROLLING_BACK) {
		this.recoverNativeResource(false);
		this.recoverRemoteResource(false);
	}
}
 
Example 13
Source File: TransactionUtil.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static String getTransactionStateString(int state) {
    /*
     * javax.transaction.Status
     * STATUS_ACTIVE           0
     * STATUS_MARKED_ROLLBACK  1
     * STATUS_PREPARED         2
     * STATUS_COMMITTED        3
     * STATUS_ROLLEDBACK       4
     * STATUS_UNKNOWN          5
     * STATUS_NO_TRANSACTION   6
     * STATUS_PREPARING        7
     * STATUS_COMMITTING       8
     * STATUS_ROLLING_BACK     9
     */
    switch (state) {
        case Status.STATUS_ACTIVE:
            return "Transaction Active (" + state + ")";
        case Status.STATUS_COMMITTED:
            return "Transaction Committed (" + state + ")";
        case Status.STATUS_COMMITTING:
            return "Transaction Committing (" + state + ")";
        case Status.STATUS_MARKED_ROLLBACK:
            return "Transaction Marked Rollback (" + state + ")";
        case Status.STATUS_NO_TRANSACTION:
            return "No Transaction (" + state + ")";
        case Status.STATUS_PREPARED:
            return "Transaction Prepared (" + state + ")";
        case Status.STATUS_PREPARING:
            return "Transaction Preparing (" + state + ")";
        case Status.STATUS_ROLLEDBACK:
            return "Transaction Rolledback (" + state + ")";
        case Status.STATUS_ROLLING_BACK:
            return "Transaction Rolling Back (" + state + ")";
        case Status.STATUS_UNKNOWN:
            return "Transaction Status Unknown (" + state + ")";
        default:
            return "Not a valid state code (" + state + ")";
    }
}
 
Example 14
Source File: StatusTranslator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static TransactionStatus translate(int status) {
	TransactionStatus transactionStatus = null;
	switch ( status ) {
		case Status.STATUS_ACTIVE:
			transactionStatus = TransactionStatus.ACTIVE;
			break;
		case Status.STATUS_PREPARED:
			transactionStatus = TransactionStatus.ACTIVE;
			break;
		case Status.STATUS_PREPARING:
			transactionStatus = TransactionStatus.ACTIVE;
			break;
		case Status.STATUS_COMMITTING:
			transactionStatus = TransactionStatus.COMMITTING;
			break;
		case Status.STATUS_ROLLING_BACK:
			transactionStatus = TransactionStatus.ROLLING_BACK;
			break;
		case Status.STATUS_NO_TRANSACTION:
			transactionStatus = TransactionStatus.NOT_ACTIVE;
			break;
		case Status.STATUS_COMMITTED:
			transactionStatus = TransactionStatus.COMMITTED;
			break;
		case Status.STATUS_ROLLEDBACK:
			transactionStatus = TransactionStatus.ROLLED_BACK;
			break;
		case Status.STATUS_MARKED_ROLLBACK:
			transactionStatus = TransactionStatus.MARKED_ROLLBACK;
			break;
		default:
			break;
	}
	if ( transactionStatus == null ) {
		throw new TransactionException( "TransactionManager reported transaction status as unknwon" );
	}
	return transactionStatus;
}
 
Example 15
Source File: AbstractLuceneIndexerImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Utility method to report errors about invalid state.
 * 
 * @return - an error based on status
 */
private String buildErrorString()
{
    StringBuilder buffer = new StringBuilder(128);
    buffer.append("The indexer is unable to accept more work: ");
    switch (getStatus().getStatus())
    {
    case Status.STATUS_COMMITTED:
        buffer.append("The indexer has been committed");
        break;
    case Status.STATUS_COMMITTING:
        buffer.append("The indexer is committing");
        break;
    case Status.STATUS_MARKED_ROLLBACK:
        buffer.append("The indexer is marked for rollback");
        break;
    case Status.STATUS_PREPARED:
        buffer.append("The indexer is prepared to commit");
        break;
    case Status.STATUS_PREPARING:
        buffer.append("The indexer is preparing to commit");
        break;
    case Status.STATUS_ROLLEDBACK:
        buffer.append("The indexer has been rolled back");
        break;
    case Status.STATUS_ROLLING_BACK:
        buffer.append("The indexer is rolling back");
        break;
    case Status.STATUS_UNKNOWN:
        buffer.append("The indexer is in an unknown state");
        break;
    default:
        break;
    }
    return buffer.toString();
}
 
Example 16
Source File: LazyUserTransaction.java    From lastaflute with Apache License 2.0 4 votes vote down vote up
protected static String buildLazyTxExp() {
    final int status;
    try {
        final TransactionManager manager = ContainerUtil.getComponent(TransactionManager.class); // for static use
        status = manager.getStatus();
    } catch (SystemException e) {
        throw new IllegalStateException("Failed to get status from transaction manager.", e);
    }
    final String statusExp;
    if (status == Status.STATUS_ACTIVE) {
        statusExp = "Active";
    } else if (status == Status.STATUS_MARKED_ROLLBACK) {
        statusExp = "MarkedRollback";
    } else if (status == Status.STATUS_PREPARED) {
        statusExp = "Prepared";
    } else if (status == Status.STATUS_COMMITTED) {
        statusExp = "Committed";
    } else if (status == Status.STATUS_ROLLEDBACK) {
        statusExp = "RolledBack";
    } else if (status == Status.STATUS_UNKNOWN) {
        statusExp = "Unknown";
    } else if (status == Status.STATUS_NO_TRANSACTION) {
        statusExp = "NoTransaction";
    } else if (status == Status.STATUS_PREPARING) {
        statusExp = "Preparing";
    } else if (status == Status.STATUS_COMMITTING) {
        statusExp = "Committing";
    } else if (status == Status.STATUS_ROLLING_BACK) {
        statusExp = "RollingBack";
    } else {
        statusExp = String.valueOf(status);
    }
    final StringBuilder sb = new StringBuilder();
    sb.append("[").append(statusExp).append("]");
    boolean secondOrMore = false;
    if (isLazyTransactionReadyLazy()) {
        sb.append(secondOrMore ? ", " : "").append("readyLazy");
        secondOrMore = true;
    }
    if (isLazyTransactionLazyBegun()) {
        sb.append(secondOrMore ? ", " : "").append("lazyBegun");
        secondOrMore = true;
    }
    if (isLazyTransactionRealBegun()) {
        sb.append(secondOrMore ? ", " : "").append("realBegun");
        secondOrMore = true;
    }
    final Integer hierarchyLevel = getCurrentHierarchyLevel();
    if (hierarchyLevel != null) {
        sb.append(secondOrMore ? ", " : "").append("hierarchy=").append(hierarchyLevel);
        secondOrMore = true;
    }
    final List<IndependentProcessor> lazyProcessList = getLazyProcessList();
    if (!lazyProcessList.isEmpty()) {
        sb.append(secondOrMore ? ", " : "").append("lazyProcesses=").append(lazyProcessList.size());
        secondOrMore = true;
    }
    final ForcedlyBegunResumer resumer = getForcedlyBegunResumer();
    if (resumer != null) {
        sb.append(secondOrMore ? ", " : "").append("resumer=").append(DfTypeUtil.toClassTitle(resumer));
        secondOrMore = true;
    }
    return sb.toString();
}
 
Example 17
Source File: TransactionRecoveryImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void recoverCoordinator(Transaction transaction)
		throws CommitRequiredException, RollbackRequiredException, SystemException {
	CompensableManager compensableManager = this.beanFactory.getCompensableManager();
	TransactionLock compensableLock = this.beanFactory.getCompensableLock();

	org.bytesoft.transaction.TransactionContext transactionContext = transaction.getTransactionContext();
	TransactionXid xid = transactionContext.getXid();

	boolean forgetRequired = false;
	boolean locked = false;
	try {
		compensableManager.associateThread(transaction);

		switch (transaction.getTransactionStatus()) {
		case Status.STATUS_ACTIVE:
		case Status.STATUS_MARKED_ROLLBACK:
		case Status.STATUS_PREPARING:
		case Status.STATUS_UNKNOWN: /* TODO */ {
			if (transactionContext.isPropagated() == false) {
				if ((locked = compensableLock.lockTransaction(xid, this.endpoint)) == false) {
					throw new SystemException(XAException.XAER_PROTO);
				}

				transaction.recoveryRollback();
				forgetRequired = true;
			}
			break;
		}
		case Status.STATUS_ROLLING_BACK: {
			if ((locked = compensableLock.lockTransaction(xid, this.endpoint)) == false) {
				throw new SystemException(XAException.XAER_PROTO);
			}

			transaction.recoveryRollback();
			forgetRequired = true;
			break;
		}
		case Status.STATUS_PREPARED:
		case Status.STATUS_COMMITTING: {
			if ((locked = compensableLock.lockTransaction(xid, this.endpoint)) == false) {
				throw new SystemException(XAException.XAER_PROTO);
			}

			transaction.recoveryCommit();
			forgetRequired = true;
			break;
		}
		case Status.STATUS_COMMITTED:
		case Status.STATUS_ROLLEDBACK:
			forgetRequired = true;
			break;
		default: // ignore
		}
	} finally {
		compensableManager.desociateThread();
		if (locked) {
			compensableLock.unlockTransaction(xid, this.endpoint);
		} // end-if (locked)
		if (forgetRequired) {
			transaction.forgetQuietly(); // forget transaction
		} // end-if (forgetRequired)
	}

}
 
Example 18
Source File: MithraManager.java    From reladomo with Apache License 2.0 4 votes vote down vote up
private boolean isStatusActive(int status)
{
    return status == Status.STATUS_ACTIVE       || status == Status.STATUS_COMMITTING  ||
           status == Status.STATUS_PREPARED     || status == Status.STATUS_PREPARING   ||
           status == Status.STATUS_ROLLING_BACK || status == Status.STATUS_MARKED_ROLLBACK;
}
 
Example 19
Source File: AbstractLuceneIndexerImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Prepare to commit At the moment this makes sure we have all the locks TODO: This is not doing proper
 * serialisation against the index as would a data base transaction.
 * 
 * @return the tx state
 * @throws LuceneIndexException
 */
public int prepare() throws LuceneIndexException
{
    if (s_logger.isDebugEnabled())
    {
        s_logger.debug(Thread.currentThread().getName() + " Starting Prepare");
    }
    switch (getStatus().getStatus())
    {
    case Status.STATUS_COMMITTING:
        throw new IndexerException("Unable to prepare: Transaction is committing");
    case Status.STATUS_COMMITTED:
        throw new IndexerException("Unable to prepare: Transaction is commited ");
    case Status.STATUS_ROLLING_BACK:
        throw new IndexerException("Unable to prepare: Transaction is rolling back");
    case Status.STATUS_ROLLEDBACK:
        throw new IndexerException("Unable to prepare: Transaction is aleady rolled back");
    case Status.STATUS_MARKED_ROLLBACK:
        throw new IndexerException("Unable to prepare: Transaction is marked for roll back");
    case Status.STATUS_PREPARING:
        throw new IndexerException("Unable to prepare: Transaction is already preparing");
    case Status.STATUS_PREPARED:
        throw new IndexerException("Unable to prepare: Transaction is already prepared");
    default:
        try
        {
            setStatus(TransactionStatus.PREPARING);
            if (isModified())
            {
                doPrepare();
                if (s_logger.isDebugEnabled())
                {
                    s_logger.debug(Thread.currentThread().getName() + " Waiting to Finish Preparing");
                }                    
            }
            setStatus(TransactionStatus.PREPARED);
            return isModified() ? XAResource.XA_OK : XAResource.XA_RDONLY;
        }
        catch (LuceneIndexException e)
        {
            setRollbackOnly();
            if (s_logger.isDebugEnabled())
            {
                s_logger.debug(Thread.currentThread().getName() + " Prepare Failed", e);
            }
            throw new LuceneIndexException("Index failed to prepare", e);
        }
        catch (Throwable t)
        {
            // If anything goes wrong we try and do a roll back
            rollback();
            if (s_logger.isDebugEnabled())
            {
                s_logger.debug(Thread.currentThread().getName() + " Prepare Failed", t);
            }
            throw new LuceneIndexException("Prepared failed", t);                
        }
        finally
        {
            if (s_logger.isDebugEnabled())
            {
                s_logger.debug(Thread.currentThread().getName() + " Ending Prepare");
            }                
        }
    }
}
 
Example 20
Source File: CoreUserTransaction.java    From tomee with Apache License 2.0 4 votes vote down vote up
private static String getStatus(final int status) {
    final StringBuilder buffer = new StringBuilder(100);
    switch (status) {
        case Status.STATUS_ACTIVE:
            buffer.append("STATUS_ACTIVE: ");
            buffer.append("A transaction is associated with the target object and it is in the active state.");
            break;
        case Status.STATUS_COMMITTED:
            buffer.append("STATUS_COMMITTED: ");
            buffer.append("A transaction is associated with the target object and it has been committed.");
            break;
        case Status.STATUS_COMMITTING:
            buffer.append("STATUS_COMMITTING: ");
            buffer.append("A transaction is associated with the target object and it is in the process of committing.");
            break;
        case Status.STATUS_MARKED_ROLLBACK:
            buffer.append("STATUS_MARKED_ROLLBACK: ");
            buffer.append("A transaction is associated with the target object and it has been marked for rollback, perhaps as a result of a setRollbackOnly operation.");
            break;
        case Status.STATUS_NO_TRANSACTION:
            buffer.append("STATUS_NO_TRANSACTION: ");
            buffer.append("No transaction is currently associated with the target object.");
            break;
        case Status.STATUS_PREPARED:
            buffer.append("STATUS_PREPARED: ");
            buffer.append("A transaction is associated with the target object and it has been prepared, i.e.");
            break;
        case Status.STATUS_PREPARING:
            buffer.append("STATUS_PREPARING: ");
            buffer.append("A transaction is associated with the target object and it is in the process of preparing.");
            break;
        case Status.STATUS_ROLLEDBACK:
            buffer.append("STATUS_ROLLEDBACK: ");
            buffer.append("A transaction is associated with the target object and the outcome has been determined as rollback.");
            break;
        case Status.STATUS_ROLLING_BACK:
            buffer.append("STATUS_ROLLING_BACK: ");
            buffer.append("A transaction is associated with the target object and it is in the process of rolling back.");
            break;
        default:
            buffer.append("Unknown status ").append(status);
            break;
    }
    return buffer.toString();
}