use of org.apache.jena.sparql.JenaTransactionException in project jena by apache.
the class AbstractTestTransactionLifecycle method testAbortAbort.
private void testAbortAbort(ReadWrite mode) {
assumeTrue(supportsAbort());
Dataset ds = create();
ds.begin(mode);
ds.abort();
try {
ds.abort();
fail("Expected transaction exception - abort-abort(" + mode + ")");
} catch (JenaTransactionException ex) {
ds.end();
}
}
use of org.apache.jena.sparql.JenaTransactionException in project jena by apache.
the class Transaction method close.
/**
* transaction close happens after commit/abort
* read transactions "auto commit" on close().
* write transactions must call abort or commit.
*/
public void close() {
// Log.info(this, "Peek = "+peekCount+"; count = "+count);
JenaTransactionException throwThis = null;
synchronized (this) {
switch(state) {
case CLOSED:
// Can call close() repeatedly.
return;
case ACTIVE:
if (mode == ReadWrite.READ) {
commit();
outcome = TxnOutcome.R_CLOSED;
} else {
// Application error: begin(WRITE)...end() with no commit() or abort().
abort();
String msg = "end() called for WRITE transaction without commit or abort having been called. This causes a forced abort.";
throwThis = new JenaTransactionException(msg);
// Keep going to clear up.
}
break;
default:
}
state = TxnState.CLOSED;
// Clear per-transaction temporary state.
if (iterators != null)
iterators.clear();
}
// Called once.
txnMgr.notifyClose(this);
if (throwThis != null)
throw throwThis;
}
use of org.apache.jena.sparql.JenaTransactionException in project jena by apache.
the class TransactionalNull method begin.
@Override
public void begin(TxnType type) {
if (inTransaction.get())
throw new JenaTransactionException("Already in transaction");
inTransaction.set(true);
txnType.set(type);
txnMode.set(TxnType.initial(type));
}
Aggregations