/** * @see Transaction#rollback() * @throws DatastoreIOException if the underlying client throws {@link DatastoreException} */ void rollback() throws DatastoreIOException { try { tx.rollback(); } catch (DatastoreException e) { throw new DatastoreIOException(e); } }
private StorageTransaction newTransaction() throws TransactionException { final CheckedDatastoreTransaction transaction; try { transaction = datastore.newTransaction(); } catch (DatastoreIOException e) { throw new TransactionException(e.getCause()); } return storageTransactionFactory.apply(transaction); }
@Override public void commit() throws TransactionException { try { tx.commit(); } catch (DatastoreIOException e) { throw new TransactionException(e.getCause()); } }
/** * @see Transaction#commit() * @throws DatastoreIOException if the underlying client throws {@link DatastoreException} */ Response commit() throws DatastoreIOException { try { return tx.commit(); } catch (DatastoreException e) { throw new DatastoreIOException(e); } }
@Override public void rollback() throws TransactionException { try { tx.rollback(); } catch (DatastoreIOException e) { throw new TransactionException(e.getCause()); } }
/** * Invokes a {@link Supplier} and translates {@link DatastoreException} and {@link RuntimeIOException} * to checked exceptions. * @throws DatastoreIOException if {@code f} threw {@link DatastoreException} * @throws IOException if {@code f} threw {@link RuntimeIOException} */ static <T> T call(Supplier<T> f) throws IOException { try { return f.get(); } catch (DatastoreException e) { // Wrap unchecked DatastoreException in a checked DatastoreIOException throw new DatastoreIOException(e); } catch (RuntimeIOException e) { // Propagate IOException from lambda throw e.getCause(); } }
/** * @see Datastore#newTransaction() * @throws DatastoreIOException if the underlying client throws {@link DatastoreException} */ CheckedDatastoreTransaction newTransaction() throws DatastoreIOException { try { return new CheckedDatastoreTransaction(this, datastore.newTransaction()); } catch (DatastoreException e) { throw new DatastoreIOException(e); } }