Copilot commented on code in PR #13856:
URL: https://github.com/apache/gravitino/pull/13856#discussion_r4278423995


##########
catalogs/catalog-jdbc-common/src/test/java/org/apache/gravitino/catalog/jdbc/TestJdbcCatalogOperationsProbe.java:
##########
@@ -92,6 +101,34 @@ public void 
testProbeAgainstAcceptButSilentServerIsBounded() throws Exception {
     }
   }
 
+  /**
+   * A driver that lives only in the catalog's libs directory is invisible to 
{@link DriverManager}
+   * until its class is initialized, and the lazy pool has not done that yet 
when the create-time
+   * probe runs. The probe must still find it instead of failing with "No 
suitable driver".
+   */
+  @Test
+  public void testProbeFindsDriverVisibleOnlyToCatalogClassLoader() throws 
Exception {
+    List<URL> urls = new ArrayList<>();
+    for (String entry : 
System.getProperty("java.class.path").split(File.pathSeparator)) {
+      urls.add(new File(entry).toURI().toURL());
+    }
+    ClassLoader original = Thread.currentThread().getContextClassLoader();
+    try (URLClassLoader catalogLoader =
+        new URLClassLoader(urls.toArray(new URL[0]), 
ClassLoader.getPlatformClassLoader())) {
+      Thread.currentThread().setContextClassLoader(catalogLoader);

Review Comment:
   If this test performs the JVM's first JDBC lookup, `DriverManager` runs its 
one-time service discovery with the isolated context loader. SQLite can then be 
registered only through that loader, so a later parent-loader lookup such as 
`TestJdbcCatalogOperations.testCloseDeregisterDriver` can fail with "No 
suitable driver". Run discovery under the original context loader before 
switching loaders to avoid this test-order dependency.



-- 
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]

Reply via email to