/** {@inheritDoc} */ @SuppressWarnings({"ThrowableInstanceNeverThrown"}) @Override public GridFuture<GridCacheTx> commitAsync() { if (log.isDebugEnabled()) log.debug("Committing near local tx: " + this); prepareAsync(); GridNearTxFinishFuture<K, V> fut = commitFut.get(); if (fut == null && !commitFut.compareAndSet(null, fut = new GridNearTxFinishFuture<K, V>(cctx, this, true))) return commitFut.get(); cctx.mvcc().addFuture(fut); prepFut .get() .listenAsync( new CI1<GridFuture<GridCacheTxEx<K, V>>>() { @Override public void apply(GridFuture<GridCacheTxEx<K, V>> f) { try { // Make sure that here are no exceptions. f.get(); finish(true); commitFut.get().finish(); } catch (Error e) { commitErr.compareAndSet(null, e); throw e; } catch (RuntimeException e) { commitErr.compareAndSet(null, e); throw e; } catch (GridException e) { commitErr.compareAndSet(null, e); commitFut.get().onError(e); } } }); return fut; }