dprmfl commented on code in PR #19231:
URL: https://github.com/apache/druid/pull/19231#discussion_r3272046348


##########
sql/src/test/java/org/apache/druid/sql/avatica/DruidAvaticaHandlerTest.java:
##########
@@ -1950,4 +1950,91 @@ private static Map<String, Object> row(final 
Pair<String, ?>... entries)
     }
     return m;
   }
+
+  /**
+   * Test that remote address is properly captured and logged for JDBC Avatica 
connections.
+   * This verifies the fix for issue #19230 which ensures that the client's 
remote address
+   * is tracked through the entire SQL execution lifecycle.
+   */
+  @Test
+  public void testRemoteAddressInLogs() throws SQLException
+  {
+    testRequestLogger.clear();
+
+    try (Statement stmt = client.createStatement()) {
+      stmt.executeQuery("SELECT COUNT(*) AS cnt FROM druid.foo");
+    }
+
+    Assert.assertEquals(1, testRequestLogger.getSqlQueryLogs().size());
+    RequestLogLine logLine = testRequestLogger.getSqlQueryLogs().get(0);
+
+    String remoteAddress = logLine.getRemoteAddr();
+    Assert.assertNotNull("Remote address should not be null", remoteAddress);
+
+    Assert.assertTrue(
+        "Remote address should be a valid IP or localhost",
+        remoteAddress.contains("localhost") ||
+        remoteAddress.contains("127.0.0.1") ||
+        remoteAddress.contains("0:0:0:0:0:0:0:1") ||
+        (remoteAddress.contains(".") && remoteAddress.length() >= 7)

Review Comment:
   fixed 
https://github.com/apache/druid/pull/19231/changes/a931b6e6c46b8caf1bb7a3eb4c9bccf94a8ae285



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to