diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reflect-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reflect-config.json index 1dc769c670433..8e93128a54e97 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reflect-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reflect-config.json @@ -3,6 +3,10 @@ "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource"}, "name":"JdkLogger" }, +{ + "condition":{"typeReachable":"org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine"}, + "name":"JdkLogger" +}, { "condition":{"typeReachable":"org.apache.shardingsphere.mode.repository.standalone.jdbc.sql.JDBCRepositorySQLLoader"}, "name":"[Lcom.fasterxml.jackson.databind.deser.BeanDeserializerModifier;" @@ -24,7 +28,7 @@ "name":"[Lcom.github.dockerjava.api.model.VolumesFrom;" }, { - "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.connection.DriverDatabaseConnectionManager$$Lambda/0x00007f2633df9040"}, + "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.connection.DriverDatabaseConnectionManager$$Lambda/0x00007fe65bdf1000"}, "name":"[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;" }, { @@ -745,6 +749,11 @@ "queryAllPublicConstructors":true, "methods":[{"name":"","parameterTypes":[] }, {"name":"add","parameterTypes":["long"] }, {"name":"sum","parameterTypes":[] }] }, +{ + "condition":{"typeReachable":"org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask"}, + "name":"java.util.concurrent.atomic.Striped64$Cell", + "fields":[{"name":"value"}] +}, { "condition":{"typeReachable":"org.apache.shardingsphere.infra.expr.groovy.GroovyInlineExpressionParser"}, "name":"java.util.function.DoubleFunction", diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/resource-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/resource-config.json index 02d27e5931fa6..af9d205fa9f56 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/resource-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/resource-config.json @@ -91,7 +91,7 @@ "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.connection.DriverDatabaseConnectionManager"}, "pattern":"\\QMETA-INF/services/com.clickhouse.client.ClickHouseClient\\E" }, { - "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.connection.DriverDatabaseConnectionManager$$Lambda/0x00007f2633ca3d10"}, + "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.connection.DriverDatabaseConnectionManager$$Lambda/0x00007fe65bca0858"}, "pattern":"\\QMETA-INF/services/com.clickhouse.client.ClickHouseClient\\E" }, { "condition":{"typeReachable":"org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource"}, @@ -271,7 +271,7 @@ "condition":{"typeReachable":"org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.Portal"}, "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.infra.executor.checker.SQLExecutionChecker\\E" }, { - "condition":{"typeReachable":"org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine"}, + "condition":{"typeReachable":"org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.Portal"}, "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.infra.executor.sql.hook.SQLExecutionHook\\E" }, { "condition":{"typeReachable":"org.apache.shardingsphere.infra.executor.sql.prepare.AbstractExecutionPrepareEngine"}, diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/resource-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/resource-config.json index 4b68f0d1a8746..936c53b8f1ab3 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/resource-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/resource-config.json @@ -14,6 +14,9 @@ "pattern":"\\QMETA-INF/services/javax.xml.parsers.SAXParserFactory\\E" }]}, "bundles":[{ + "name":"com.sun.org.apache.xml.internal.serializer.XMLEntities", + "locales":["en"] + }, { "name":"com.microsoft.sqlserver.jdbc.SQLServerResource", "locales":["en"] }, { diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/proxy/ProxyTestingServer.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/proxy/ProxyTestingServer.java index 00e2ea233ca0a..326db2e1b34bf 100644 --- a/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/proxy/ProxyTestingServer.java +++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/proxy/ProxyTestingServer.java @@ -19,12 +19,16 @@ import lombok.Getter; import org.apache.curator.test.InstanceSpec; +import org.apache.shardingsphere.mode.manager.ContextManager; import org.apache.shardingsphere.proxy.Bootstrap; import org.apache.shardingsphere.proxy.backend.context.ProxyContext; +import org.testcontainers.shaded.org.awaitility.Awaitility; +import javax.sql.DataSource; import java.io.IOException; import java.sql.SQLException; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; /** * This class is designed to start ShardingSphere Proxy directly in the current process, @@ -48,7 +52,7 @@ public final class ProxyTestingServer { public ProxyTestingServer(final String configAbsolutePath) { completableFuture = CompletableFuture.runAsync(() -> { try { - Bootstrap.main(new String[]{String.valueOf(proxyPort), configAbsolutePath, "0.0.0.0", "false"}); + Bootstrap.main(new String[]{String.valueOf(proxyPort), configAbsolutePath, "0.0.0.0"}); } catch (final IOException | SQLException ex) { throw new RuntimeException(ex); } @@ -56,10 +60,25 @@ public ProxyTestingServer(final String configAbsolutePath) { } /** - * Force close ShardingSphere Proxy. See {@link org.apache.shardingsphere.proxy.frontend.ShardingSphereProxy#close}. + * Force close ShardingSphere Proxy. + * For all Proxy related unit tests, the virtual database name is agreed to be `sharding_db`. + * See {@link org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource#close()} and + * {@link org.apache.shardingsphere.proxy.frontend.ShardingSphereProxy#close}. */ public void close() { - ProxyContext.getInstance().getContextManager().close(); completableFuture.cancel(false); + Awaitility.await().atMost(1L, TimeUnit.MINUTES).until(completableFuture::isDone); + ContextManager contextManager = ProxyContext.getInstance().getContextManager(); + contextManager.getStorageUnits("sharding_db").values().forEach(storageUnit -> { + DataSource dataSource = storageUnit.getDataSource(); + if (dataSource instanceof AutoCloseable) { + try { + ((AutoCloseable) dataSource).close(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + }); + contextManager.close(); } }