You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/07/16 10:49:30 UTC

[32/50] [abbrv] incubator-ignite git commit: # IGNITE-1097 (IgniteFuture.chain() unwraps exceptions incorrectly.) (cherry picked from commit b131c81)

# IGNITE-1097 (IgniteFuture.chain() unwraps exceptions incorrectly.)
(cherry picked from commit b131c81)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/98c57e00
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/98c57e00
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/98c57e00

Branch: refs/heads/ignite-901
Commit: 98c57e00676dd22e7f92c3c95b85c6039f902021
Parents: 3dcf891
Author: sevdokimov <se...@jetbrains.com>
Authored: Thu Jul 9 16:04:54 2015 +0300
Committer: sevdokimov <se...@jetbrains.com>
Committed: Fri Jul 10 10:47:35 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/98c57e00/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/98c57e00/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/98c57e00/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> {