ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-7904: Changed IgniteUtils::cast not to trim exception chains. This closes #3683.
Date Mon, 09 Apr 2018 11:33:21 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 834869c2a -> 3a4f23bfe


IGNITE-7904: Changed IgniteUtils::cast not to trim exception chains. This closes #3683.


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

Branch: refs/heads/master
Commit: 3a4f23bfebbbc515ecafdf9b97cf1b5d99d5dbf6
Parents: 834869c
Author: Stanislav Lukyanov <lukyanov.lsa@gmail.com>
Authored: Mon Apr 9 14:33:13 2018 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Mon Apr 9 14:33:13 2018 +0300

----------------------------------------------------------------------
 .../ignite/compute/ComputeTaskAdapter.java      |   2 +-
 .../processors/cache/GridCacheUtils.java        |   5 +-
 .../processors/cache/IgniteCacheProxyImpl.java  |   3 +
 .../processors/igfs/IgfsMetaManager.java        |  30 ++-
 .../internal/processors/job/GridJobWorker.java  |   2 +-
 .../platform/services/PlatformServices.java     |   8 +-
 .../processors/service/GridServiceProxy.java    |  27 ++-
 .../ignite/internal/util/IgniteUtils.java       |  32 +---
 .../IgniteComputeResultExceptionTest.java       | 186 +++++++++++++++++++
 .../cache/GridCacheAbstractFullApiSelfTest.java |   9 +-
 .../closure/GridClosureSerializationTest.java   |   2 +-
 .../GridServiceProcessorProxySelfTest.java      |  12 +-
 .../testsuites/IgniteComputeGridTestSuite.java  |   2 +
 ...niteCacheLockPartitionOnAffinityRunTest.java |  46 ++---
 .../jdbc/CacheJdbcPojoStoreFactorySelfTest.java |  11 +-
 .../resource/GridServiceInjectionSelfTest.java  |  64 +++----
 .../GridSpringResourceInjectionSelfTest.java    |  58 +++---
 17 files changed, 339 insertions(+), 160 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/main/java/org/apache/ignite/compute/ComputeTaskAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/compute/ComputeTaskAdapter.java
b/modules/core/src/main/java/org/apache/ignite/compute/ComputeTaskAdapter.java
index c5352aa..fc55ad9 100644
--- a/modules/core/src/main/java/org/apache/ignite/compute/ComputeTaskAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/compute/ComputeTaskAdapter.java
@@ -99,7 +99,7 @@ public abstract class ComputeTaskAdapter<T, R> implements ComputeTask<T,
R> {
                 return ComputeJobResultPolicy.FAILOVER;
 
             throw new IgniteException("Remote job threw user exception (override or implement
ComputeTask.result(..) " +
-                "method if you would like to have automatic failover for this exception).",
e);
+                "method if you would like to have automatic failover for this exception):
" + e.getMessage(), e);
         }
 
         // Wait for all job responses.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 09a96d3..83ce2ba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -1283,8 +1283,9 @@ public class GridCacheUtils {
         else if (e instanceof SchemaOperationException)
             return new CacheException(e.getMessage(), e);
 
-        if (e.getCause() instanceof CacheException)
-            return (CacheException)e.getCause();
+        CacheException ce = X.cause(e, CacheException.class);
+        if (ce != null)
+            return ce;
 
         if (e.getCause() instanceof NullPointerException)
             return (NullPointerException)e.getCause();

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
index c5d68b5..be4b0db 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
@@ -1727,6 +1727,9 @@ public class IgniteCacheProxyImpl<K, V> extends AsyncSupportAdapter<IgniteCache<
                         ctx.name(), e);
         }
 
+        if (e instanceof IgniteException && X.hasCause(e, CacheException.class))
+            e = X.cause(e, CacheException.class);
+
         if (e instanceof IgniteCheckedException)
             return CU.convertToCacheException((IgniteCheckedException) e);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index a26239c..e821b80 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -89,6 +89,7 @@ import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
 import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.T1;
+import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.transactions.TransactionConcurrency;
@@ -254,28 +255,19 @@ public class IgfsMetaManager extends IgfsManager {
      */
     <T> T runClientTask(IgfsClientAbstractCallable<T> task) {
         try {
-            return runClientTask(IgfsUtils.ROOT_ID, task);
-        }
-        catch (ClusterTopologyException e) {
-            throw new IgfsException("Failed to execute operation because there are no IGFS
metadata nodes." , e);
-        }
-    }
-
-    /**
-     * Run client task.
-     *
-     * @param affinityFileId Affinity fileId.
-     * @param task Task.
-     * @return Result.
-     */
-    <T> T runClientTask(IgniteUuid affinityFileId, IgfsClientAbstractCallable<T>
task) {
-        try {
             return (cfg.isColocateMetadata()) ?
-                clientCompute().affinityCall(metaCacheName, affinityFileId, task) :
+                clientCompute().affinityCall(metaCacheName, IgfsUtils.ROOT_ID, task) :
                 clientCompute().call(task);
         }
-        catch (ClusterTopologyException e) {
-            throw new IgfsException("Failed to execute operation because there are no IGFS
metadata nodes." , e);
+        catch (Exception e) {
+            if (X.hasCause(e, ClusterTopologyException.class))
+                throw new IgfsException("Failed to execute operation because there are no
IGFS metadata nodes." , e);
+
+            IgfsException igfsEx = X.cause(e, IgfsException.class);
+            if (igfsEx != null)
+                throw igfsEx;
+
+            throw e;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
index cce1077..6d2e621 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
@@ -678,7 +678,7 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject
{
 
         if (msg == null) {
             msg = "Failed to execute job due to unexpected runtime exception [jobId=" + ses.getJobId()
+
-                ", ses=" + ses + ']';
+                ", ses=" + ses + ", err=" + e.getMessage() + ']';
 
             ex = new ComputeUserUndeclaredException(msg, e);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
index ccb04d4..4ae59b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
 import org.apache.ignite.internal.processors.platform.utils.PlatformWriterBiClosure;
 import org.apache.ignite.internal.processors.platform.utils.PlatformWriterClosure;
 import org.apache.ignite.internal.processors.service.GridServiceProxy;
+import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.typedef.T3;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgnitePredicate;
@@ -581,7 +582,12 @@ public class PlatformServices extends PlatformAbstractTarget {
 
                 Method mtd = getMethod(serviceClass, mthdName, args);
 
-                return ((GridServiceProxy)proxy).invokeMethod(mtd, args);
+                try {
+                    return ((GridServiceProxy)proxy).invokeMethod(mtd, args);
+                }
+                catch (Throwable t) {
+                    throw IgniteUtils.cast(t);
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
index e55c2e5..c5a2cee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
@@ -47,6 +47,7 @@ import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
 import org.apache.ignite.internal.managers.communication.GridIoPolicy;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteCallable;
@@ -150,7 +151,7 @@ public class GridServiceProxy<T> implements Serializable {
      * @return Result.
      */
     @SuppressWarnings("BusyWait")
-    public Object invokeMethod(final Method mtd, final Object[] args) {
+    public Object invokeMethod(final Method mtd, final Object[] args) throws Throwable {
         if (U.isHashCodeMethod(mtd))
             return System.identityHashCode(proxy);
         else if (U.isEqualsMethod(mtd))
@@ -205,6 +206,12 @@ public class GridServiceProxy<T> implements Serializable {
                     throw e;
                 }
                 catch (IgniteCheckedException e) {
+                    // Rethrow original service method exception so that calling user code
can handle it correctly.
+                    ServiceProxyException svcProxyE = X.cause(e, ServiceProxyException.class);
+
+                    if (svcProxyE != null)
+                        throw svcProxyE.getCause();
+
                     throw U.convertException(e);
                 }
                 catch (Exception e) {
@@ -352,7 +359,7 @@ public class GridServiceProxy<T> implements Serializable {
 
         /** {@inheritDoc} */
         @SuppressWarnings("BusyWait")
-        @Override public Object invoke(Object proxy, final Method mtd, final Object[] args)
{
+        @Override public Object invoke(Object proxy, final Method mtd, final Object[] args)
throws Throwable {
             return invokeMethod(mtd, args);
         }
     }
@@ -418,8 +425,7 @@ public class GridServiceProxy<T> implements Serializable {
                 return mtd.invoke(svcCtx.service(), args);
             }
             catch (InvocationTargetException e) {
-                // Get error message.
-                throw new IgniteCheckedException(e.getCause().getMessage(), e);
+                throw new ServiceProxyException(e.getCause());
             }
         }
 
@@ -444,4 +450,17 @@ public class GridServiceProxy<T> implements Serializable {
             return S.toString(ServiceProxyCallable.class, this);
         }
     }
+
+    /**
+     * Exception class that wraps an exception thrown by the service implementation.
+     */
+    private static class ServiceProxyException extends RuntimeException {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** {@inheritDoc} */
+        ServiceProxyException(Throwable cause) {
+            super(cause);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 18e182d..93f4fb4 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -7285,35 +7285,23 @@ public abstract class IgniteUtils {
     }
 
     /**
-     * Casts this throwable as {@link IgniteCheckedException}. Creates wrapping
-     * {@link IgniteCheckedException}, if needed.
+     * Casts the passed {@code Throwable t} to {@link IgniteCheckedException}.<br>
+     * If {@code t} is a {@link GridClosureException}, it is unwrapped and then cast to {@link
IgniteCheckedException}.
+     * If {@code t} is an {@link IgniteCheckedException}, it is returned.
+     * If {@code t} is not a {@link IgniteCheckedException}, a new {@link IgniteCheckedException}
caused by {@code t}
+     * is returned.
      *
      * @param t Throwable to cast.
-     * @return Grid exception.
+     * @return {@code t} cast to {@link IgniteCheckedException}.
      */
     public static IgniteCheckedException cast(Throwable t) {
         assert t != null;
 
-        while (true) {
-            if (t instanceof Error)
-                throw (Error)t;
+        t = unwrap(t);
 
-            if (t instanceof GridClosureException) {
-                t = ((GridClosureException)t).unwrap();
-
-                continue;
-            }
-
-            if (t instanceof IgniteCheckedException)
-                return (IgniteCheckedException)t;
-
-            if (!(t instanceof IgniteException) || t.getCause() == null)
-                return new IgniteCheckedException(t);
-
-            assert t.getCause() != null; // ...and it is IgniteException.
-
-            t = t.getCause();
-        }
+        return t instanceof IgniteCheckedException
+            ? (IgniteCheckedException)t
+            : new IgniteCheckedException(t);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeResultExceptionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeResultExceptionTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeResultExceptionTest.java
new file mode 100644
index 0000000..fab5de6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeResultExceptionTest.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeJobResultPolicy;
+import org.apache.ignite.compute.ComputeTask;
+import org.apache.ignite.compute.ComputeTaskFuture;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Testing that if {@link ComputeTask#result(ComputeJobResult, List)} throws an {@link IgniteException}
+ * then that exception is thrown as the execution result.
+ */
+public class IgniteComputeResultExceptionTest extends GridCommonAbstractTest {
+    /** */
+    public void testIgniteExceptionExecute() throws Exception {
+        checkExecuteException(new IgniteException());
+    }
+
+    /** */
+    public void testIgniteExceptionWithCauseExecute() throws Exception {
+        checkExecuteException(new IgniteException(new Exception()));
+    }
+
+    /** */
+    public void testIgniteExceptionWithCauseChainExecute() throws Exception {
+        checkExecuteException(new IgniteException(new Exception(new Throwable())));
+    }
+
+    /** */
+    public void testCustomExceptionExecute() throws Exception {
+        checkExecuteException(new TaskException());
+    }
+
+    /** */
+    public void testCustomExceptionWithCauseExecute() throws Exception {
+        checkExecuteException(new TaskException(new Exception()));
+    }
+
+    /** */
+    public void testCustomExceptionWithCauseChainExecute() throws Exception {
+        checkExecuteException(new TaskException(new Exception(new Throwable())));
+    }
+
+    /** */
+    private void checkExecuteException(IgniteException resE) throws Exception {
+        try (Ignite ignite = startGrid()) {
+            IgniteCompute compute = ignite.compute();
+            try {
+                compute.execute(new ResultExceptionTask(resE), null);
+            } catch (IgniteException e) {
+                assertSame(resE, e);
+            }
+        }
+    }
+
+    /** */
+    public void testIgniteExceptionExecuteAsync() throws Exception {
+        checkExecuteAsyncException(new IgniteException());
+    }
+
+    /** */
+    public void testIgniteExceptionWithCauseExecuteAsync() throws Exception {
+        checkExecuteAsyncException(new IgniteException(new Exception()));
+    }
+
+    /** */
+    public void testIgniteExceptionWithCauseChainExecuteAsync() throws Exception {
+        checkExecuteAsyncException(new IgniteException(new Exception(new Throwable())));
+    }
+
+
+    /** */
+    public void testCustomExceptionExecuteAsync() throws Exception {
+        checkExecuteAsyncException(new TaskException());
+    }
+
+    /** */
+    public void testCustomExceptionWithCauseExecuteAsync() throws Exception {
+        checkExecuteAsyncException(new TaskException(new Exception()));
+    }
+
+    /** */
+    public void testCustomExceptionWithCauseChainExecuteAsync() throws Exception {
+        checkExecuteAsyncException(new TaskException(new Exception(new Throwable())));
+    }
+
+    /** */
+    private void checkExecuteAsyncException(IgniteException resE) throws Exception {
+        try (Ignite ignite = startGrid()) {
+            IgniteCompute compute = ignite.compute();
+            ComputeTaskFuture<Object> fut = compute.executeAsync(new ResultExceptionTask(resE),
null);
+            try {
+                fut.get();
+            } catch (IgniteException e) {
+                assertSame(resE, e);
+            }
+        }
+    }
+
+    /** */
+    private static class TaskException extends IgniteException {
+        /** */
+        public TaskException() {
+            // No-op.
+        }
+
+        /** */
+        public TaskException(Throwable cause) {
+            super(cause);
+        }
+    }
+
+    /** */
+    private static class NoopJob implements ComputeJob {
+        /** */
+        @Override public void cancel() {
+            // No-op.
+        }
+
+        /** */
+        @Override public Object execute() throws IgniteException {
+            return null;
+        }
+    }
+
+    /** */
+    private static class ResultExceptionTask implements ComputeTask<Object, Object>
{
+        /** */
+        private final IgniteException resE;
+
+        /**
+         * @param resE Exception to be rethrown by the
+         */
+        ResultExceptionTask(IgniteException resE) {
+            this.resE = resE;
+        }
+
+        /** */
+        @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode>
subgrid,
+            @Nullable Object arg) throws IgniteException {
+            Map<ComputeJob, ClusterNode> jobs = new HashMap<>();
+
+            for (ClusterNode node : subgrid)
+                jobs.put(new NoopJob(), node);
+
+            return jobs;
+        }
+
+        /** */
+        @Override
+        public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult>
rcvd) throws IgniteException {
+            throw resE;
+        }
+
+        /** */
+        @Nullable @Override public Object reduce(List<ComputeJobResult> results) throws
IgniteException {
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/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 2e6a19c..e5df2c8 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
@@ -82,6 +82,7 @@ import org.apache.ignite.internal.util.lang.IgnitePair;
 import org.apache.ignite.internal.util.typedef.CIX1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.PA;
+import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -5041,12 +5042,16 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
 
                 checkIteratorsCleared();
             }
-            catch (AssertionFailedError e) {
+            catch (Throwable t) {
+                // If AssertionFailedError is in the chain, assume we need to wait and retry.
+                if (!X.hasCause(t, AssertionFailedError.class))
+                    throw t;
+                
                 if (i == 9) {
                     for (int j = 0; j < gridCount(); j++)
                         executeOnLocalOrRemoteJvm(j, new PrintIteratorStateTask());
 
-                    throw e;
+                    throw t;
                 }
 
                 log.info("Iterators not cleared, will wait");

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureSerializationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureSerializationTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureSerializationTest.java
index 8bcbd81..324a9e9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureSerializationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureSerializationTest.java
@@ -68,7 +68,7 @@ public class GridClosureSerializationTest extends GridCommonAbstractTest
{
         final IgniteEx ignite0 = grid(0);
         final IgniteEx ignite1 = grid(1);
 
-        GridTestUtils.assertThrows(null, new Callable<Object>() {
+        GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
                 ignite1.compute(ignite1.cluster().forNode(ignite0.localNode())).call(new
IgniteCallable<Object>() {
                     @Override public Object call() throws Exception {

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorProxySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorProxySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorProxySelfTest.java
index d1c5294..97d5f05 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorProxySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorProxySelfTest.java
@@ -89,7 +89,7 @@ public class GridServiceProcessorProxySelfTest extends GridServiceProcessorAbstr
 
                 return null;
             }
-        }, IgniteException.class, "Test exception");
+        }, ErrorServiceException.class, "Test exception");
 
     }
 
@@ -450,9 +450,15 @@ public class GridServiceProcessorProxySelfTest extends GridServiceProcessorAbstr
 
         /** {@inheritDoc} */
         @Override public void go() throws Exception {
-            throw new Exception("Test exception");
+            throw new ErrorServiceException("Test exception");
         }
     }
 
-
+    /** */
+    private static class ErrorServiceException extends Exception {
+        /** */
+        ErrorServiceException(String msg) {
+            super(msg);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
index 2ffa11e..55fab8d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
@@ -67,6 +67,7 @@ import org.apache.ignite.internal.GridTaskResultCacheSelfTest;
 import org.apache.ignite.internal.GridTaskTimeoutSelfTest;
 import org.apache.ignite.internal.IgniteComputeEmptyClusterGroupTest;
 import org.apache.ignite.internal.IgniteComputeJobOneThreadTest;
+import org.apache.ignite.internal.IgniteComputeResultExceptionTest;
 import org.apache.ignite.internal.IgniteComputeTopologyExceptionTest;
 import org.apache.ignite.internal.IgniteExecutorServiceTest;
 import org.apache.ignite.internal.IgniteExplicitImplicitDeploymentSelfTest;
@@ -156,6 +157,7 @@ public class IgniteComputeGridTestSuite {
         suite.addTestSuite(GridMultinodeRedeployIsolatedModeSelfTest.class);
         suite.addTestSuite(IgniteComputeEmptyClusterGroupTest.class);
         suite.addTestSuite(IgniteComputeTopologyExceptionTest.class);
+        suite.addTestSuite(IgniteComputeResultExceptionTest.class);
         suite.addTestSuite(GridTaskFailoverAffinityRunTest.class);
         suite.addTestSuite(TaskNodeRestartTest.class);
         suite.addTestSuite(IgniteRoundRobinErrorAfterClientReconnectTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
index 598212b..7bddafc 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
@@ -23,6 +23,7 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteException;
@@ -404,39 +405,20 @@ public class IgniteCacheLockPartitionOnAffinityRunTest extends IgniteCacheLockPa
     public void testCheckReservePartitionException() throws Exception {
         int orgId = primaryKey(grid(1).cache(Organization.class.getSimpleName()));
 
-        try {
-            grid(0).compute().affinityRun(
-                Arrays.asList(Organization.class.getSimpleName(), OTHER_CACHE_NAME),
-                new Integer(orgId),
-                new IgniteRunnable() {
-                    @Override public void run() {
-                        // No-op.
-                    }
-                });
-
-            fail("Exception is expected");
-        }
-        catch (Exception e) {
-            assertTrue(e.getMessage()
-                .startsWith("Failed partition reservation. Partition is not primary on the
node."));
-        }
-
-        try {
-            grid(0).compute().affinityCall(
-                Arrays.asList(Organization.class.getSimpleName(), OTHER_CACHE_NAME),
-                new Integer(orgId),
-                new IgniteCallable<Object>() {
-                    @Override public Object call() throws Exception {
-                        return null;
-                    }
-                });
+        GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                grid(0).compute().affinityRun(
+                    Arrays.asList(Organization.class.getSimpleName(), OTHER_CACHE_NAME),
+                    new Integer(orgId),
+                    new IgniteRunnable() {
+                        @Override public void run() {
+                            // No-op.
+                        }
+                    });
 
-            fail("Exception is expected");
-        }
-        catch (Exception e) {
-            assertTrue(e.getMessage()
-                .startsWith("Failed partition reservation. Partition is not primary on the
node."));
-        }
+                return null;
+            }
+        }, IgniteException.class, "Failed partition reservation. Partition is not primary
on the node.");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactorySelfTest.java
b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactorySelfTest.java
index 0fd16f0..0d6d6a2 100644
--- a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactorySelfTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactorySelfTest.java
@@ -21,7 +21,7 @@ import java.util.Collection;
 import java.util.concurrent.Callable;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.store.jdbc.dialect.H2Dialect;
 import org.apache.ignite.cache.store.jdbc.dialect.JdbcDialect;
@@ -69,15 +69,14 @@ public class CacheJdbcPojoStoreFactorySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testIncorrectBeanConfiguration() throws Exception {
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
+        GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
-                try(Ignite ignite = Ignition.start("modules/spring/src/test/config/pojo-incorrect-store-cache.xml"))
{
-                    ignite.cache(CACHE_NAME).getConfiguration(CacheConfiguration.class).
-                        getCacheStoreFactory().create();
+                try (Ignite ignored = Ignition.start("modules/spring/src/test/config/pojo-incorrect-store-cache.xml"))
{
+                    // No-op.
                 }
                 return null;
             }
-        }, IgniteException.class, "Spring bean with provided name doesn't exist");
+        }, IgniteCheckedException.class, "Spring bean with provided name doesn't exist");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridServiceInjectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridServiceInjectionSelfTest.java
b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridServiceInjectionSelfTest.java
index b59bf24..52581b6 100644
--- a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridServiceInjectionSelfTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridServiceInjectionSelfTest.java
@@ -18,11 +18,13 @@
 package org.apache.ignite.internal.processors.resource;
 
 import java.io.Serializable;
-import org.apache.ignite.IgniteException;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.lang.IgniteCallable;
 import org.apache.ignite.resources.ServiceResource;
 import org.apache.ignite.services.Service;
 import org.apache.ignite.services.ServiceContext;
+import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 /**
@@ -124,23 +126,22 @@ public class GridServiceInjectionSelfTest extends GridCommonAbstractTest
impleme
      * @throws Exception If failed.
      */
     public void testClosureFieldWithIncorrectType() throws Exception {
-        try {
-            grid(0).compute().call(new IgniteCallable<Object>() {
-                @ServiceResource(serviceName = SERVICE_NAME1)
-                private String svcName;
+        GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() {
+            @Override public Void call() {
+                grid(0).compute().call(new IgniteCallable<Object>() {
+                    @ServiceResource(serviceName = SERVICE_NAME1)
+                    private String svcName;
 
-                @Override public Object call() throws Exception {
-                    fail();
+                    @Override public Object call() throws Exception {
+                        fail();
 
-                    return null;
-                }
-            });
+                        return null;
+                    }
+                });
 
-            fail();
-        }
-        catch (IgniteException e) {
-            assertTrue(e.getMessage().startsWith("Resource field is not assignable from the
resource"));
-        }
+                return null;
+            }
+        }, IgniteCheckedException.class, "Resource field is not assignable from the resource");
     }
 
     /**
@@ -221,23 +222,22 @@ public class GridServiceInjectionSelfTest extends GridCommonAbstractTest
impleme
      * @throws Exception If failed.
      */
     public void testClosureMethodWithIncorrectType() throws Exception {
-        try {
-            grid(0).compute().call(new IgniteCallable<Object>() {
-                @ServiceResource(serviceName = SERVICE_NAME1)
-                private void service(String svcs) {
-                    fail();
-                }
-
-                @Override public Object call() throws Exception {
-                    return null;
-                }
-            });
-
-            fail();
-        }
-        catch (IgniteException e) {
-            assertTrue(e.getMessage().startsWith("Setter does not have single parameter of
required type"));
-        }
+        GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() {
+            @Override public Void call() {
+                grid(0).compute().call(new IgniteCallable<Object>() {
+                    @ServiceResource(serviceName = SERVICE_NAME1)
+                    private void service(String svcs) {
+                        fail();
+                    }
+
+                    @Override public Object call() throws Exception {
+                        return null;
+                    }
+                });
+
+                return null;
+            }
+        }, IgniteCheckedException.class, "Setter does not have single parameter of required
type");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4f23bf/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridSpringResourceInjectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridSpringResourceInjectionSelfTest.java
b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridSpringResourceInjectionSelfTest.java
index 827dd72..08fe69d 100644
--- a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridSpringResourceInjectionSelfTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridSpringResourceInjectionSelfTest.java
@@ -27,6 +27,8 @@ import org.apache.ignite.lang.IgniteCallable;
 import org.apache.ignite.resources.SpringResource;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
@@ -93,7 +95,7 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
         Ignite anotherGrid = IgniteSpring.start(anotherCfg, new ClassPathXmlApplicationContext(
             "/org/apache/ignite/internal/processors/resource/spring-resource-with-duplicate-beans.xml"));
 
-        Throwable err = assertError(new IgniteCallable<Object>() {
+        assertError(new IgniteCallable<Object>() {
             @SpringResource(resourceClass = DummyResourceBean.class)
             private transient DummyResourceBean dummyRsrcBean;
 
@@ -102,11 +104,9 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
 
                 return null;
             }
-        }, anotherGrid, null);
-
-        assertTrue("Unexpected message: " + err.getMessage(), err.getMessage().startsWith("No
qualifying bean of type " +
+        }, anotherGrid, NoUniqueBeanDefinitionException.class, "No qualifying bean of type
" +
             "'org.apache.ignite.internal.processors.resource.GridSpringResourceInjectionSelfTest$DummyResourceBean'"
+
-            " available: expected single matching bean but found 2:"));
+            " available: expected single matching bean but found 2:");
 
         G.stop("anotherGrid", false);
     }
@@ -124,7 +124,7 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
 
                 return null;
             }
-        }, "No bean named 'nonExistentResource' available");
+        }, grid, NoSuchBeanDefinitionException.class, "No bean named 'nonExistentResource'
available");
     }
 
     /**
@@ -140,7 +140,7 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
 
                 return null;
             }
-        }, "No qualifying bean of type 'org.apache.ignite.internal.processors.resource."
+
+        }, grid, NoSuchBeanDefinitionException.class, "No qualifying bean of type 'org.apache.ignite.internal.processors.resource."
+
             "GridSpringResourceInjectionSelfTest$AnotherDummyResourceBean' available");
     }
 
@@ -157,7 +157,7 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
 
                 return null;
             }
-        }, "Either bean name or its class must be specified in @SpringResource, but not both");
+        }, grid, IgniteException.class, "Either bean name or its class must be specified
in @SpringResource, but not both");
     }
 
     /**
@@ -173,7 +173,7 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
 
                 return null;
             }
-        }, "Either bean name or its class must be specified in @SpringResource, but not both");
+        }, grid, IgniteException.class, "Either bean name or its class must be specified
in @SpringResource, but not both");
     }
 
     /**
@@ -232,7 +232,7 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
             "/org/apache/ignite/internal/processors/resource/spring-resource-with-duplicate-beans.xml"));
 
         try {
-            Throwable err = assertError(new IgniteCallable<Object>() {
+            assertError(new IgniteCallable<Object>() {
                 private DummyResourceBean dummyRsrcBean;
 
                 @SpringResource(resourceClass = DummyResourceBean.class)
@@ -247,11 +247,9 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
 
                     return null;
                 }
-            }, anotherGrid, null);
-
-            assertTrue("Unexpected message: " + err.getMessage(), err.getMessage().startsWith("No
qualifying bean of type " +
+            }, anotherGrid, NoUniqueBeanDefinitionException.class, "No qualifying bean of
type " +
                 "'org.apache.ignite.internal.processors.resource.GridSpringResourceInjectionSelfTest$DummyResourceBean'"
+
-                " available: expected single matching bean but found 2:"));
+                " available: expected single matching bean but found 2:");
         }
         finally {
             G.stop("anotherGrid", false);
@@ -275,7 +273,7 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
 
                 return null;
             }
-        }, "No bean named 'nonExistentResource' available");
+        }, grid, NoSuchBeanDefinitionException.class, "No bean named 'nonExistentResource'
available");
     }
 
     /**
@@ -295,7 +293,7 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
 
                 return null;
             }
-        }, "No qualifying bean of type 'org.apache.ignite.internal.processors.resource" +
+        }, grid, NoSuchBeanDefinitionException.class,"No qualifying bean of type 'org.apache.ignite.internal.processors.resource"
+
             ".GridSpringResourceInjectionSelfTest$AnotherDummyResourceBean' available");
     }
 
@@ -312,7 +310,7 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
 
                 return null;
             }
-        }, "Either bean name or its class must be specified in @SpringResource, but not both");
+        }, grid, IgniteException.class, "Either bean name or its class must be specified
in @SpringResource, but not both");
     }
 
     /**
@@ -328,32 +326,24 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest
 
                 return null;
             }
-        }, "Either bean name or its class must be specified in @SpringResource, but not both");
+        }, grid, IgniteException.class, "Either bean name or its class must be specified
in @SpringResource, but not both");
     }
 
     /**
-     * @param job {@link IgniteCallable} to be run
-     * @param grid Node.
-     * @param expEMsg Message that {@link IgniteException} thrown from <tt>job</tt>
should bear
-     * @return Thrown error.
+     * @param job {@link IgniteCallable} to be run.
+     * @param grid Node to run the job on.
+     * @param expE Expected exception type.
+     * @param expEMsg Expected exception message.
      */
     @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
-    private Throwable assertError(final IgniteCallable<?> job, final Ignite grid, String
expEMsg) {
-        return GridTestUtils.assertThrows(log, new Callable<Object>() {
+    private void assertError(final IgniteCallable<?> job, final Ignite grid, Class<?
extends Throwable> expE,
+        String expEMsg) {
+        GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
                 grid.compute(grid.cluster().forLocal()).call(job);
                 return null;
             }
-        }, IgniteException.class, expEMsg);
-    }
-
-    /**
-     * @param job {@link IgniteCallable} to be run
-     * @param expEMsg Message that {@link IgniteException} thrown from <tt>job</tt>
should bear
-     */
-    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
-    private void assertError(final IgniteCallable<?> job, String expEMsg) {
-        assertError(job, grid, expEMsg);
+        }, expE, expEMsg);
     }
 
     /**


Mime
View raw message