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

isapego pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 4fdf7b8f3c IGNITE-22865 Thin 3: Add a hint to enable the full stack 
trace (#4558)
4fdf7b8f3c is described below

commit 4fdf7b8f3cdc1c9477c95611f51001b15f34b91d
Author: Igor Sapego <[email protected]>
AuthorDate: Tue Oct 15 10:58:11 2024 +0200

    IGNITE-22865 Thin 3: Add a hint to enable the full stack trace (#4558)
---
 .../client/handler/ItClientHandlerMetricsTest.java  |  2 +-
 .../ignite/client/handler/ItClientHandlerTest.java  |  9 ++++-----
 .../client/handler/ClientInboundMessageHandler.java |  2 +-
 .../runner/app/client/ItThinClientComputeTest.java  | 21 ++++++++++++++++-----
 .../app/client/ItThinClientConnectionTest.java      |  9 +++++++++
 5 files changed, 31 insertions(+), 12 deletions(-)

diff --git 
a/modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/ItClientHandlerMetricsTest.java
 
b/modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/ItClientHandlerMetricsTest.java
index f1f4dc3bc6..583e1d461f 100644
--- 
a/modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/ItClientHandlerMetricsTest.java
+++ 
b/modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/ItClientHandlerMetricsTest.java
@@ -181,7 +181,7 @@ public class ItClientHandlerMetricsTest extends 
BaseIgniteAbstractTest {
         ItClientHandlerTestUtils.connectAndHandshake(serverModule, false, 
true);
 
         assertTrue(
-                IgniteTestUtils.waitForCondition(() -> 
testServer.metrics().bytesSent() == 210, 1000),
+                IgniteTestUtils.waitForCondition(() -> 
testServer.metrics().bytesSent() == 302, 1000),
                 () -> "bytesSent: " + testServer.metrics().bytesSent());
 
         assertTrue(
diff --git 
a/modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/ItClientHandlerTest.java
 
b/modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/ItClientHandlerTest.java
index 2d9972e037..a31e98d665 100644
--- 
a/modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/ItClientHandlerTest.java
+++ 
b/modules/client-handler/src/integrationTest/java/org/apache/ignite/client/handler/ItClientHandlerTest.java
@@ -28,7 +28,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.containsString;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -228,7 +227,7 @@ public class ItClientHandlerTest extends 
BaseIgniteAbstractTest {
                     
"org.apache.ignite.security.exception.UnsupportedAuthenticationTypeException",
                     errClassName
             );
-            assertNull(errStackTrace);
+            assertEquals("To see the full stack trace set 
clientConnector.sendServerExceptionStackTraceToClient:true", errStackTrace);
         }
     }
 
@@ -354,7 +353,7 @@ public class ItClientHandlerTest extends 
BaseIgniteAbstractTest {
 
             assertThat(errMsg, containsString("Authentication failed"));
             
assertEquals("org.apache.ignite.security.exception.InvalidCredentialsException",
 errClassName);
-            assertNull(errStackTrace);
+            assertEquals("To see the full stack trace set 
clientConnector.sendServerExceptionStackTraceToClient:true", errStackTrace);
         }
     }
 
@@ -409,7 +408,7 @@ public class ItClientHandlerTest extends 
BaseIgniteAbstractTest {
 
             assertThat(errMsg, containsString("Authentication failed"));
             
assertEquals("org.apache.ignite.security.exception.InvalidCredentialsException",
 errClassName);
-            assertNull(errStackTrace);
+            assertEquals("To see the full stack trace set 
clientConnector.sendServerExceptionStackTraceToClient:true", errStackTrace);
         }
     }
 
@@ -462,7 +461,7 @@ public class ItClientHandlerTest extends 
BaseIgniteAbstractTest {
 
             assertThat(errMsg, containsString("Unsupported version: 2.8.0"));
             assertEquals("org.apache.ignite.lang.IgniteException", 
errClassName);
-            assertNull(errStackTrace);
+            assertEquals("To see the full stack trace set 
clientConnector.sendServerExceptionStackTraceToClient:true", errStackTrace);
         }
     }
 
diff --git 
a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientInboundMessageHandler.java
 
b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientInboundMessageHandler.java
index c734dd3c33..2f17bd03c7 100644
--- 
a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientInboundMessageHandler.java
+++ 
b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientInboundMessageHandler.java
@@ -560,7 +560,7 @@ public class ClientInboundMessageHandler extends 
ChannelInboundHandlerAdapter im
         if (configuration.sendServerExceptionStackTraceToClient()) {
             packer.packString(ExceptionUtils.getFullStackTrace(pubErr));
         } else {
-            packer.packNil();
+            packer.packString("To see the full stack trace set 
clientConnector.sendServerExceptionStackTraceToClient:true");
         }
 
         // Extensions.
diff --git 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeTest.java
 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeTest.java
index 87a33ba6ae..edcdf6db72 100644
--- 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeTest.java
+++ 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeTest.java
@@ -47,7 +47,6 @@ import static 
org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -334,7 +333,10 @@ public class ItThinClientComputeTest extends 
ItAbstractThinClientTest {
         assertEquals(TRACE_ID, cause.traceId());
         assertEquals(COLUMN_ALREADY_EXISTS_ERR, cause.code());
         assertInstanceOf(CustomException.class, cause);
-        assertNull(cause.getCause()); // No stack trace by default.
+        assertNotNull(cause.getCause());
+        String hint = cause.getCause().getMessage();
+
+        assertEquals("To see the full stack trace set 
clientConnector.sendServerExceptionStackTraceToClient:true", hint);
     }
 
     @Test
@@ -347,7 +349,10 @@ public class ItThinClientComputeTest extends 
ItAbstractThinClientTest {
         assertEquals(TRACE_ID, cause.traceId());
         assertEquals(COLUMN_ALREADY_EXISTS_ERR, cause.code());
         assertInstanceOf(CustomException.class, cause);
-        assertNull(cause.getCause()); // No stack trace by default.
+        assertNotNull(cause.getCause());
+        String hint = cause.getCause().getMessage();
+
+        assertEquals("To see the full stack trace set 
clientConnector.sendServerExceptionStackTraceToClient:true", hint);
     }
 
     @ParameterizedTest
@@ -535,7 +540,10 @@ public class ItThinClientComputeTest extends 
ItAbstractThinClientTest {
         String expectedMessage = "Job execution failed: 
java.lang.ArithmeticException: math err";
         assertTraceableException(cause, ComputeException.class, 
COMPUTE_JOB_FAILED_ERR, expectedMessage);
 
-        assertNull(cause.getCause()); // No stack trace by default.
+        assertNotNull(cause.getCause());
+        String hint = cause.getCause().getMessage();
+
+        assertEquals("To see the full stack trace set 
clientConnector.sendServerExceptionStackTraceToClient:true", hint);
     }
 
     private static void assertComputeExceptionWithStackTrace(IgniteException 
cause) {
@@ -758,7 +766,10 @@ public class ItThinClientComputeTest extends 
ItAbstractThinClientTest {
         assertEquals(TRACE_ID, cause.traceId());
         assertEquals(COLUMN_ALREADY_EXISTS_ERR, cause.code());
         assertInstanceOf(CustomException.class, cause);
-        assertNull(cause.getCause()); // No stack trace by default.
+        assertNotNull(cause.getCause());
+        String hint = cause.getCause().getMessage();
+
+        assertEquals("To see the full stack trace set 
clientConnector.sendServerExceptionStackTraceToClient:true", hint);
     }
 
     private void testEchoArg(Object arg) {
diff --git 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java
 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java
index 8711085459..be83feefc3 100644
--- 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java
+++ 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java
@@ -116,4 +116,13 @@ public class ItThinClientConnectionTest extends 
ItAbstractThinClientTest {
             channel.heartbeatAsync(w -> w.out().writePayload(new byte[]{1, 2, 
3})).join();
         }
     }
+
+    @Test
+    void testExceptionHasHint() {
+        var client = 
IgniteClient.builder().addresses(getClientAddresses().get(0)).build();
+
+        IgniteException ex = assertThrows(IgniteException.class, () -> 
client.sql().execute(null, "select x from bad"));
+        assertEquals("To see the full stack trace set 
clientConnector.sendServerExceptionStackTraceToClient:true",
+                ex.getCause().getCause().getCause().getCause().getMessage());
+    }
 }

Reply via email to