This is an automated email from the ASF dual-hosted git repository.

namelchev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 84a2d58f577 IGNITE-23794 Fixed send a stack trace to a thin client if 
task fails on map phase. (#11687)
84a2d58f577 is described below

commit 84a2d58f5770be61c805adba3417f43d27d399ec
Author: Ravil <[email protected]>
AuthorDate: Tue Dec 3 14:57:09 2024 +0300

    IGNITE-23794 Fixed send a stack trace to a thin client if task fails on map 
phase. (#11687)
---
 .../platform/client/IgniteClientException.java     |  2 +-
 .../platform/client/compute/ClientComputeTask.java |  8 +++--
 .../internal/client/thin/ComputeTaskTest.java      | 40 ++++++++++++++++++++--
 3 files changed, 45 insertions(+), 5 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/IgniteClientException.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/IgniteClientException.java
index 487bb84d64f..959c6ca5f95 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/IgniteClientException.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/IgniteClientException.java
@@ -47,7 +47,7 @@ public class IgniteClientException extends IgniteException {
      * @param msg Message.
      * @param cause Cause.
      */
-    public IgniteClientException(int statusCode, String msg, Exception cause) {
+    public IgniteClientException(int statusCode, String msg, Throwable cause) {
         super(msg, cause);
 
         this.statusCode = statusCode;
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/compute/ClientComputeTask.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/compute/ClientComputeTask.java
index e1a392e47e8..fbc91b95ea0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/compute/ClientComputeTask.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/compute/ClientComputeTask.java
@@ -113,8 +113,12 @@ class ClientComputeTask implements ClientCloseableResource 
{
         taskFut = task.execute(taskName, arg, opts);
 
         // Fail fast.
-        if (taskFut.isDone() && taskFut.error() != null)
-            throw new IgniteClientException(ClientStatus.FAILED, 
taskFut.error().getMessage());
+        if (taskFut.isDone() && taskFut.error() != null) {
+            if 
(ctx.kernalContext().clientListener().sendServerExceptionStackTraceToClient())
+                throw new IgniteClientException(ClientStatus.FAILED, 
taskFut.error().getMessage(), taskFut.error());
+            else
+                throw new IgniteClientException(ClientStatus.FAILED, 
taskFut.error().getMessage());
+        }
     }
 
     /**
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ComputeTaskTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ComputeTaskTest.java
index 6d6b96dc5cd..3a91d733cae 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ComputeTaskTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ComputeTaskTest.java
@@ -55,6 +55,9 @@ import org.apache.ignite.testframework.GridTestUtils;
 import org.jetbrains.annotations.Nullable;
 import org.junit.Test;
 
+import static org.apache.ignite.testframework.GridTestUtils.assertContains;
+import static org.apache.ignite.testframework.GridTestUtils.assertNotContains;
+
 /**
  * Checks compute grid functionality of thin client.
  */
@@ -75,8 +78,9 @@ public class ComputeTaskTest extends AbstractThinClientTest {
     @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
         return 
super.getConfiguration(igniteInstanceName).setClientConnectorConfiguration(
             new ClientConnectorConfiguration().setThinClientConfiguration(
-                new 
ThinClientConfiguration().setMaxActiveComputeTasksPerConnection(
-                    getTestIgniteInstanceIndex(igniteInstanceName) <= 1 ? 
ACTIVE_TASKS_LIMIT : 0)))
+                new ThinClientConfiguration()
+                    
.setMaxActiveComputeTasksPerConnection(getTestIgniteInstanceIndex(igniteInstanceName)
 <= 1 ? ACTIVE_TASKS_LIMIT : 0)
+                    
.setServerToClientExceptionStackTraceSending(getTestIgniteInstanceIndex(igniteInstanceName)
 == 1)))
             .setClientMode(getTestIgniteInstanceIndex(igniteInstanceName) == 
3);
     }
 
@@ -233,6 +237,38 @@ public class ComputeTaskTest extends 
AbstractThinClientTest {
         }
     }
 
+    /**
+     * Tests task execution with an exception and no stacktrace in error 
message (by default).
+     */
+    @Test
+    public void testSendNoStackTraceOnTaskMapFail() throws Exception {
+        try (IgniteClient client = startClient(0)) {
+            client.compute().execute(TestExceptionalTask.class.getName(), 
null);
+
+            fail();
+        }
+        catch (Exception e) {
+            assertNotContains(log, e.getMessage(), "Caused by: 
java.lang.ArithmeticException: Foo");
+            assertContains(log, e.getMessage(), "Failed to map task jobs to 
nodes due to undeclared user exception");
+            assertContains(log, e.getMessage(), "cause=Foo");
+        }
+    }
+
+    /**
+     * Tests task execution with an exception and full stacktrace in error 
message.
+     */
+    @Test
+    public void testSendStackTraceOnTaskMapFail() throws Exception {
+        try (IgniteClient client = startClient(1)) {
+            client.compute().execute(TestExceptionalTask.class.getName(), 
null);
+
+            fail();
+        }
+        catch (Exception e) {
+            assertContains(log, e.getMessage(), "Caused by: 
java.lang.ArithmeticException: Foo");
+        }
+    }
+
     /**
      *
      */

Reply via email to