Repository: incubator-ignite Updated Branches: refs/heads/ignite-1097 [created] b131c81bf
# IGNITE-1097 (IgniteFuture.chain() unwraps exceptions incorrectly.) Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b131c81b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b131c81b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b131c81b Branch: refs/heads/ignite-1097 Commit: b131c81bf2b8610a219e152de80aad62901a9720 Parents: 546d595 Author: sevdokimov <sergey.evdoki...@jetbrains.com> Authored: Thu Jul 9 16:04:54 2015 +0300 Committer: sevdokimov <sergey.evdoki...@jetbrains.com> Committed: Thu Jul 9 16:04:54 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/IgniteCacheFutureImpl.java | 6 ++++ .../internal/util/future/IgniteFutureImpl.java | 12 ++++++-- .../cache/GridCacheAbstractFullApiSelfTest.java | 32 ++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b131c81b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheFutureImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheFutureImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheFutureImpl.java index 06c28e6..42e31d2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheFutureImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheFutureImpl.java @@ -21,6 +21,7 @@ import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.util.future.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; /** * Implementation of public API future for cache. @@ -36,6 +37,11 @@ public class IgniteCacheFutureImpl<V> extends IgniteFutureImpl<V> { } /** {@inheritDoc} */ + @Override public <T> IgniteFuture<T> chain(IgniteClosure<? super IgniteFuture<V>, T> doneCb) { + return new IgniteCacheFutureImpl<>(chainInternal(doneCb)); + } + + /** {@inheritDoc} */ @Override protected RuntimeException convertException(IgniteCheckedException e) { return CU.convertToCacheException(e); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b131c81b/modules/core/src/main/java/org/apache/ignite/internal/util/future/IgniteFutureImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/IgniteFutureImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/util/future/IgniteFutureImpl.java index 764e0ea..13d564d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/IgniteFutureImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/IgniteFutureImpl.java @@ -78,7 +78,15 @@ public class IgniteFutureImpl<V> implements IgniteFuture<V> { /** {@inheritDoc} */ @Override public <T> IgniteFuture<T> chain(final IgniteClosure<? super IgniteFuture<V>, T> doneCb) { - IgniteInternalFuture<T> fut0 = fut.chain(new C1<IgniteInternalFuture<V>, T>() { + return new IgniteFutureImpl<>(chainInternal(doneCb)); + } + + /** + * @param doneCb Done callback. + * @return Internal future + */ + protected <T> IgniteInternalFuture<T> chainInternal(final IgniteClosure<? super IgniteFuture<V>, T> doneCb) { + return fut.chain(new C1<IgniteInternalFuture<V>, T>() { @Override public T apply(IgniteInternalFuture<V> fut) { assert IgniteFutureImpl.this.fut == fut; @@ -90,8 +98,6 @@ public class IgniteFutureImpl<V> implements IgniteFuture<V> { } } }); - - return new IgniteFutureImpl<>(fut0); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b131c81b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index 151c249..3f9c365 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -62,6 +62,14 @@ import static org.apache.ignite.transactions.TransactionState.*; * Full API cache test. */ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstractSelfTest { + /** */ + public static final CacheEntryProcessor<String, Integer, String> ERR_PROCESSOR = + new CacheEntryProcessor<String, Integer, String>() { + @Override public String process(MutableEntry<String, Integer> e, Object... args) { + throw new RuntimeException("Failed!"); + } + }; + /** Increment processor for invoke operations. */ public static final EntryProcessor<String, Integer, String> INCR_PROCESSOR = new EntryProcessor<String, Integer, String>() { @Override public String process(MutableEntry<String, Integer> e, Object... args) { @@ -4993,6 +5001,30 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract } /** + * @throws Exception If failed. + */ + public void testTransformException() throws Exception { + final IgniteCache<String, Integer> cache = jcache().withAsync(); + + cache.invoke("key2", ERR_PROCESSOR); + + assertThrows(log, new Callable<Object>() { + @Override public Object call() throws Exception { + + IgniteFuture fut = cache.future().chain(new IgniteClosure<IgniteFuture, Object>() { + @Override public Object apply(IgniteFuture o) { + return o.get(); + } + }); + + fut.get(); + + return null; + } + }, EntryProcessorException.class, null); + } + + /** * Sets given value, returns old value. */ public static final class SetValueProcessor implements EntryProcessor<String, Integer, Integer> {