From c8e5545dd90fe15ea457db58d66cf498d7043041 Mon Sep 17 00:00:00 2001 From: linghengqian Date: Sun, 12 Nov 2023 13:12:15 +0800 Subject: [PATCH] Fixes JAXB error --- ...ssBasedInlineShardingAlgorithmFixture.java | 44 ++ .../resource-config.json | 9 + .../nativetest/src/test/resources/logback.xml | 34 -- .../src/test/resources/yaml/sharding.yaml | 8 +- .../jni-config.json | 2 +- .../proxy-config.json | 2 +- .../reflect-config.json | 429 +++++------------- .../resource-config.json | 14 +- .../serialization-config.json | 2 +- .../jdbc/sql/JDBCRepositorySQLLoader.java | 35 +- 10 files changed, 219 insertions(+), 360 deletions(-) create mode 100644 infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ClassBasedInlineShardingAlgorithmFixture.java create mode 100644 infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-infra-nativetest-test-image/resource-config.json delete mode 100644 infra/nativetest/src/test/resources/logback.xml diff --git a/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ClassBasedInlineShardingAlgorithmFixture.java b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ClassBasedInlineShardingAlgorithmFixture.java new file mode 100644 index 00000000000000..f5b97920b461c3 --- /dev/null +++ b/infra/nativetest/src/test/java/org/apache/shardingsphere/infra/nativetest/jdbc/features/ClassBasedInlineShardingAlgorithmFixture.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.infra.nativetest.jdbc.features; + +import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue; +import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue; +import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm; + +import java.util.Collection; + +@SuppressWarnings("unused") +public final class ClassBasedInlineShardingAlgorithmFixture implements StandardShardingAlgorithm { + + @Override + public String doSharding(final Collection availableTargetNames, final PreciseShardingValue shardingValue) { + String resultDatabaseName = "ds_" + shardingValue.getValue() % 2; + for (String each : availableTargetNames) { + if (each.equals(resultDatabaseName)) { + return each; + } + } + return null; + } + + @Override + public Collection doSharding(final Collection availableTargetNames, final RangeShardingValue shardingValue) { + throw new RuntimeException("This algorithm class does not support range queries."); + } +} diff --git a/infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-infra-nativetest-test-image/resource-config.json b/infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-infra-nativetest-test-image/resource-config.json new file mode 100644 index 00000000000000..855aee2e26a1f9 --- /dev/null +++ b/infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-infra-nativetest-test-image/resource-config.json @@ -0,0 +1,9 @@ +{ + "resources":{ + "includes":[{ + "pattern":"\\Qsql/H2.xml\\E" + }, { + "pattern":"\\Qsql/MySQL.xml\\E" + }]}, + "bundles":[] +} \ No newline at end of file diff --git a/infra/nativetest/src/test/resources/logback.xml b/infra/nativetest/src/test/resources/logback.xml deleted file mode 100644 index a4847ef2c0bda2..00000000000000 --- a/infra/nativetest/src/test/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - ${log.context.name} - - - - ${log.pattern} - - - - - - - diff --git a/infra/nativetest/src/test/resources/yaml/sharding.yaml b/infra/nativetest/src/test/resources/yaml/sharding.yaml index be76577f1aab4d..4c74720b34cba0 100644 --- a/infra/nativetest/src/test/resources/yaml/sharding.yaml +++ b/infra/nativetest/src/test/resources/yaml/sharding.yaml @@ -58,10 +58,14 @@ rules: shardingColumn: user_id shardingAlgorithmName: inline shardingAlgorithms: + # GroovyShell related classes are not available on GraalVM CE 23.0.2 For JDK 17.0.9, + # This CLASS_BASE algorithm class is designed to emulate INLINE's `ds_${user_id % 2}`. + # See https://github.com/oracle/graal/issues/5522 . inline: - type: INLINE + type: CLASS_BASED props: - algorithm-expression: ds_${user_id % 2} + strategy: STANDARD + algorithmClassName: org.apache.shardingsphere.infra.nativetest.jdbc.features.ClassBasedInlineShardingAlgorithmFixture keyGenerators: snowflake: type: SNOWFLAKE diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/jni-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/jni-config.json index c8b081385033ae..0ee2739762f2dc 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/jni-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/jni-config.json @@ -7,4 +7,4 @@ "name":"sun.management.VMManagementImpl", "fields":[{"name":"compTimeMonitoringSupport"}, {"name":"currentThreadCpuTimeSupport"}, {"name":"objectMonitorUsageSupport"}, {"name":"otherThreadCpuTimeSupport"}, {"name":"remoteDiagnosticCommandsSupport"}, {"name":"synchronizerUsageSupport"}, {"name":"threadAllocatedMemorySupport"}, {"name":"threadContentionMonitoringSupport"}] } -] +] \ No newline at end of file diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/proxy-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/proxy-config.json index 641a8f15102354..fbfaf87cb7a19f 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/proxy-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/proxy-config.json @@ -2,4 +2,4 @@ { "interfaces":["java.sql.Connection"] } -] +] \ No newline at end of file diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json index 5a2d98a818c4df..653aa9b297c134 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reflect-config.json @@ -8,34 +8,61 @@ "methods":[{"name":"","parameterTypes":["groovy.lang.Binding"] }] }, { - "name":"Script1$_run_closure1", + "name":"Script1BeanInfo" +}, +{ + "name":"Script1Customizer" +}, +{ + "name":"Script2", + "allDeclaredFields":true, "queryAllDeclaredMethods":true, + "queryAllPublicMethods":true, "queryAllDeclaredConstructors":true, - "methods":[{"name":"doCall","parameterTypes":["java.lang.Object"] }] + "methods":[{"name":"","parameterTypes":["groovy.lang.Binding"] }] }, { - "name":"Script1BeanInfo" + "name":"Script2BeanInfo" }, { - "name":"Script1Customizer" + "name":"Script2Customizer" }, { - "name":"[B" + "name":"Script3", + "allDeclaredFields":true, + "queryAllDeclaredMethods":true, + "queryAllPublicMethods":true, + "queryAllDeclaredConstructors":true, + "methods":[{"name":"","parameterTypes":["groovy.lang.Binding"] }] }, { - "name":"[C" + "name":"Script3BeanInfo" }, { - "name":"[I" + "name":"Script3Customizer" }, { - "name":"[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;" + "name":"Script4", + "allDeclaredFields":true, + "queryAllDeclaredMethods":true, + "queryAllPublicMethods":true, + "queryAllDeclaredConstructors":true, + "methods":[{"name":"","parameterTypes":["groovy.lang.Binding"] }] }, { - "name":"[Ljava.io.ObjectStreamField;" + "name":"Script4BeanInfo" }, { - "name":"[Ljava.lang.CharSequence;" + "name":"Script4Customizer" +}, +{ + "name":"[B" +}, +{ + "name":"[Lcom.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry;" +}, +{ + "name":"[Ljava.io.ObjectStreamField;" }, { "name":"[Ljava.lang.Class;" @@ -79,68 +106,6 @@ { "name":"[Lsun.security.pkcs.SignerInfo;" }, -{ - "name":"ch.qos.logback.classic.encoder.PatternLayoutEncoder", - "queryAllPublicMethods":true, - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.joran.SerializedModelConfigurator", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.DateConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.LevelConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.LineSeparatorConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.LoggerConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.MessageConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.pattern.ThreadConverter", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.classic.util.DefaultJoranConfigurator", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.core.ConsoleAppender", - "queryAllPublicMethods":true, - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"ch.qos.logback.core.OutputStreamAppender", - "methods":[{"name":"setEncoder","parameterTypes":["ch.qos.logback.core.encoder.Encoder"] }] -}, -{ - "name":"ch.qos.logback.core.encoder.Encoder", - "methods":[{"name":"valueOf","parameterTypes":["java.lang.String"] }] -}, -{ - "name":"ch.qos.logback.core.encoder.LayoutWrappingEncoder", - "methods":[{"name":"setParent","parameterTypes":["ch.qos.logback.core.spi.ContextAware"] }] -}, -{ - "name":"ch.qos.logback.core.pattern.PatternLayoutEncoderBase", - "methods":[{"name":"setPattern","parameterTypes":["java.lang.String"] }] -}, -{ - "name":"ch.qos.logback.core.spi.ContextAware", - "methods":[{"name":"valueOf","parameterTypes":["java.lang.String"] }] -}, { "name":"com.github.benmanes.caffeine.cache.BBHeader$ReadAndWriteCounterRef", "fields":[{"name":"writeCounter"}] @@ -243,14 +208,15 @@ }, { "name":"com.zaxxer.hikari.HikariConfig", + "queryAllPublicMethods":true, "fields":[{"name":"dataSourceProperties"}, {"name":"jdbcUrl"}], - "methods":[{"name":"getCatalog","parameterTypes":[] }, {"name":"getConnectionInitSql","parameterTypes":[] }, {"name":"getConnectionTestQuery","parameterTypes":[] }, {"name":"getConnectionTimeout","parameterTypes":[] }, {"name":"getDataSourceClassName","parameterTypes":[] }, {"name":"getDataSourceJNDI","parameterTypes":[] }, {"name":"getDataSourceProperties","parameterTypes":[] }, {"name":"getExceptionOverrideClassName","parameterTypes":[] }, {"name":"getHealthCheckProperties","parameterTypes":[] }, {"name":"getIdleTimeout","parameterTypes":[] }, {"name":"getInitializationFailTimeout","parameterTypes":[] }, {"name":"getJdbcUrl","parameterTypes":[] }, {"name":"getKeepaliveTime","parameterTypes":[] }, {"name":"getLeakDetectionThreshold","parameterTypes":[] }, {"name":"getMaxLifetime","parameterTypes":[] }, {"name":"getMaximumPoolSize","parameterTypes":[] }, {"name":"getMinimumIdle","parameterTypes":[] }, {"name":"getPassword","parameterTypes":[] }, {"name":"getPoolName","parameterTypes":[] }, {"name":"getSchema","parameterTypes":[] }, {"name":"getTransactionIsolation","parameterTypes":[] }, {"name":"getUsername","parameterTypes":[] }, {"name":"getValidationTimeout","parameterTypes":[] }, {"name":"isAllowPoolSuspension","parameterTypes":[] }, {"name":"isAutoCommit","parameterTypes":[] }, {"name":"isIsolateInternalQueries","parameterTypes":[] }, {"name":"isReadOnly","parameterTypes":[] }, {"name":"isRegisterMbeans","parameterTypes":[] }, {"name":"setConnectionTimeout","parameterTypes":["long"] }, {"name":"setDataSourceProperties","parameterTypes":["java.util.Properties"] }, {"name":"setIdleTimeout","parameterTypes":["long"] }, {"name":"setJdbcUrl","parameterTypes":["java.lang.String"] }, {"name":"setKeepaliveTime","parameterTypes":["long"] }, {"name":"setMaxLifetime","parameterTypes":["long"] }, {"name":"setMaximumPoolSize","parameterTypes":["int"] }, {"name":"setMinimumIdle","parameterTypes":["int"] }, {"name":"setPassword","parameterTypes":["java.lang.String"] }, {"name":"setReadOnly","parameterTypes":["boolean"] }, {"name":"setUsername","parameterTypes":["java.lang.String"] }] + "methods":[{"name":"getCatalog","parameterTypes":[] }, {"name":"getConnectionInitSql","parameterTypes":[] }, {"name":"getConnectionTestQuery","parameterTypes":[] }, {"name":"getConnectionTimeout","parameterTypes":[] }, {"name":"getDataSource","parameterTypes":[] }, {"name":"getDataSourceClassName","parameterTypes":[] }, {"name":"getDataSourceJNDI","parameterTypes":[] }, {"name":"getDataSourceProperties","parameterTypes":[] }, {"name":"getDriverClassName","parameterTypes":[] }, {"name":"getExceptionOverrideClassName","parameterTypes":[] }, {"name":"getHealthCheckProperties","parameterTypes":[] }, {"name":"getHealthCheckRegistry","parameterTypes":[] }, {"name":"getIdleTimeout","parameterTypes":[] }, {"name":"getInitializationFailTimeout","parameterTypes":[] }, {"name":"getJdbcUrl","parameterTypes":[] }, {"name":"getKeepaliveTime","parameterTypes":[] }, {"name":"getLeakDetectionThreshold","parameterTypes":[] }, {"name":"getMaxLifetime","parameterTypes":[] }, {"name":"getMaximumPoolSize","parameterTypes":[] }, {"name":"getMetricRegistry","parameterTypes":[] }, {"name":"getMetricsTrackerFactory","parameterTypes":[] }, {"name":"getMinimumIdle","parameterTypes":[] }, {"name":"getPassword","parameterTypes":[] }, {"name":"getPoolName","parameterTypes":[] }, {"name":"getScheduledExecutor","parameterTypes":[] }, {"name":"getSchema","parameterTypes":[] }, {"name":"getThreadFactory","parameterTypes":[] }, {"name":"getTransactionIsolation","parameterTypes":[] }, {"name":"getUsername","parameterTypes":[] }, {"name":"getValidationTimeout","parameterTypes":[] }, {"name":"isAllowPoolSuspension","parameterTypes":[] }, {"name":"isAutoCommit","parameterTypes":[] }, {"name":"isIsolateInternalQueries","parameterTypes":[] }, {"name":"isReadOnly","parameterTypes":[] }, {"name":"isRegisterMbeans","parameterTypes":[] }, {"name":"setAllowPoolSuspension","parameterTypes":["boolean"] }, {"name":"setAutoCommit","parameterTypes":["boolean"] }, {"name":"setCatalog","parameterTypes":["java.lang.String"] }, {"name":"setClass","parameterTypes":["java.lang.Class"] }, {"name":"setConnectionInitSql","parameterTypes":["java.lang.String"] }, {"name":"setConnectionTestQuery","parameterTypes":["java.lang.String"] }, {"name":"setConnectionTimeout","parameterTypes":["long"] }, {"name":"setDataSource","parameterTypes":["javax.sql.DataSource"] }, {"name":"setDataSourceClassName","parameterTypes":["java.lang.String"] }, {"name":"setDataSourceJNDI","parameterTypes":["java.lang.String"] }, {"name":"setDataSourceProperties","parameterTypes":["java.util.Properties"] }, {"name":"setDriverClassName","parameterTypes":["java.lang.String"] }, {"name":"setExceptionOverrideClassName","parameterTypes":["java.lang.String"] }, {"name":"setHealthCheckProperties","parameterTypes":["java.util.Properties"] }, {"name":"setHealthCheckRegistry","parameterTypes":["java.lang.Object"] }, {"name":"setIdleTimeout","parameterTypes":["long"] }, {"name":"setInitializationFailTimeout","parameterTypes":["long"] }, {"name":"setIsolateInternalQueries","parameterTypes":["boolean"] }, {"name":"setJdbcUrl","parameterTypes":["java.lang.String"] }, {"name":"setKeepaliveTime","parameterTypes":["long"] }, {"name":"setLeakDetectionThreshold","parameterTypes":["long"] }, {"name":"setMaxLifetime","parameterTypes":["long"] }, {"name":"setMaximumPoolSize","parameterTypes":["int"] }, {"name":"setMetricRegistry","parameterTypes":["java.lang.Object"] }, {"name":"setMetricsTrackerFactory","parameterTypes":["com.zaxxer.hikari.metrics.MetricsTrackerFactory"] }, {"name":"setMinimumIdle","parameterTypes":["int"] }, {"name":"setPassword","parameterTypes":["java.lang.String"] }, {"name":"setPoolName","parameterTypes":["java.lang.String"] }, {"name":"setReadOnly","parameterTypes":["boolean"] }, {"name":"setRegisterMbeans","parameterTypes":["boolean"] }, {"name":"setScheduledExecutor","parameterTypes":["java.util.concurrent.ScheduledExecutorService"] }, {"name":"setSchema","parameterTypes":["java.lang.String"] }, {"name":"setThreadFactory","parameterTypes":["java.util.concurrent.ThreadFactory"] }, {"name":"setTransactionIsolation","parameterTypes":["java.lang.String"] }, {"name":"setUsername","parameterTypes":["java.lang.String"] }, {"name":"setValidationTimeout","parameterTypes":["long"] }] }, { "name":"com.zaxxer.hikari.HikariDataSource", "queryAllPublicMethods":true, "fields":[{"name":"dataSourceProperties"}, {"name":"jdbcUrl"}], - "methods":[{"name":"","parameterTypes":[] }, {"name":"isClosed","parameterTypes":[] }, {"name":"isRunning","parameterTypes":[] }] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getAllowPoolSuspension","parameterTypes":[] }, {"name":"getAutoCommit","parameterTypes":[] }, {"name":"getIsolateInternalQueries","parameterTypes":[] }, {"name":"getReadOnly","parameterTypes":[] }, {"name":"getRegisterMbeans","parameterTypes":[] }, {"name":"isClosed","parameterTypes":[] }, {"name":"isRunning","parameterTypes":[] }] }, { "name":"com.zaxxer.hikari.pool.PoolEntry", @@ -281,37 +247,12 @@ }, { "name":"groovy.lang.Buildable", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"groovy.lang.Closure", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true, - "methods":[{"name":"getProperty","parameterTypes":["java.lang.String"] }] -}, -{ - "name":"groovy.lang.Closure$1", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"groovy.lang.Closure$1BeanInfo" -}, -{ - "name":"groovy.lang.Closure$1Customizer" -}, -{ - "name":"groovy.lang.ClosureBeanInfo" -}, -{ - "name":"groovy.lang.ClosureCustomizer" + "queryAllDeclaredMethods":true }, { "name":"groovy.lang.EmptyRange" @@ -331,45 +272,19 @@ }, { "name":"groovy.lang.GString", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true, - "methods":[{"name":"build","parameterTypes":["groovy.lang.GroovyObject"] }, {"name":"charAt","parameterTypes":["int"] }, {"name":"compareTo","parameterTypes":["java.lang.Object"] }, {"name":"getStrings","parameterTypes":[] }, {"name":"length","parameterTypes":[] }, {"name":"subSequence","parameterTypes":["int","int"] }, {"name":"toString","parameterTypes":[] }, {"name":"writeTo","parameterTypes":["java.io.Writer"] }] -}, -{ - "name":"groovy.lang.GString$1", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"groovy.lang.GString$1BeanInfo" -}, -{ - "name":"groovy.lang.GString$1Customizer" -}, -{ - "name":"groovy.lang.GStringBeanInfo" -}, -{ - "name":"groovy.lang.GStringCustomizer" + "methods":[{"name":"build","parameterTypes":["groovy.lang.GroovyObject"] }, {"name":"charAt","parameterTypes":["int"] }, {"name":"compareTo","parameterTypes":["java.lang.Object"] }, {"name":"length","parameterTypes":[] }, {"name":"subSequence","parameterTypes":["int","int"] }, {"name":"toString","parameterTypes":[] }, {"name":"writeTo","parameterTypes":["java.io.Writer"] }] }, { "name":"groovy.lang.GroovyCallable", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"groovy.lang.GroovyObject", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true, - "methods":[{"name":"getProperty","parameterTypes":["java.lang.String"] }, {"name":"invokeMethod","parameterTypes":["java.lang.String","java.lang.Object"] }] + "queryAllDeclaredConstructors":true }, { "name":"groovy.lang.GroovyObjectSupport", @@ -427,20 +342,17 @@ }, { "name":"groovy.lang.MetaMethod", - "queryAllDeclaredMethods":true, - "methods":[{"name":"doMethodInvoke","parameterTypes":["java.lang.Object","java.lang.Object[]"] }] + "queryAllDeclaredMethods":true }, { "name":"groovy.lang.MetaObjectProtocol", "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "methods":[{"name":"getProperty","parameterTypes":["java.lang.Object","java.lang.String"] }, {"name":"invokeConstructor","parameterTypes":["java.lang.Object[]"] }, {"name":"invokeMethod","parameterTypes":["java.lang.Object","java.lang.String","java.lang.Object[]"] }, {"name":"invokeStaticMethod","parameterTypes":["java.lang.Object","java.lang.String","java.lang.Object[]"] }] + "queryAllPublicMethods":true }, { "name":"groovy.lang.MetaProperty", - "queryAllDeclaredMethods":true, - "methods":[{"name":"getProperty","parameterTypes":["java.lang.Object"] }] + "queryAllDeclaredMethods":true }, { "name":"groovy.lang.MutableMetaClass", @@ -473,10 +385,8 @@ }, { "name":"groovy.lang.Writable", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"groovy.lang.groovydoc.Groovydoc" @@ -484,35 +394,26 @@ { "name":"groovy.runtime.metaclass.CustomMetaClassCreationHandle" }, -{ - "name":"groovy.runtime.metaclass.Script1$_run_closure1MetaClass" -}, { "name":"groovy.runtime.metaclass.Script1MetaClass" }, { - "name":"groovy.runtime.metaclass.groovy.lang.BindingMetaClass" -}, -{ - "name":"groovy.runtime.metaclass.groovy.lang.Closure$1MetaClass" + "name":"groovy.runtime.metaclass.Script2MetaClass" }, { - "name":"groovy.runtime.metaclass.groovy.lang.ExpandoMetaClassMetaClass" + "name":"groovy.runtime.metaclass.Script3MetaClass" }, { - "name":"groovy.runtime.metaclass.groovy.lang.GString$1MetaClass" + "name":"groovy.runtime.metaclass.Script4MetaClass" }, { - "name":"groovy.runtime.metaclass.groovy.lang.GroovyShellMetaClass" -}, -{ - "name":"groovy.runtime.metaclass.groovy.util.ExpandoMetaClass" + "name":"groovy.runtime.metaclass.groovy.lang.BindingMetaClass" }, { - "name":"groovy.runtime.metaclass.java.lang.IntegerMetaClass" + "name":"groovy.runtime.metaclass.groovy.lang.ExpandoMetaClassMetaClass" }, { - "name":"groovy.runtime.metaclass.org.codehaus.groovy.runtime.GStringImplMetaClass" + "name":"groovy.runtime.metaclass.groovy.lang.GroovyShellMetaClass" }, { "name":"groovy.transform.Internal", @@ -521,19 +422,6 @@ { "name":"groovy.util.BufferedIterator" }, -{ - "name":"groovy.util.Expando", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"groovy.util.ExpandoBeanInfo" -}, -{ - "name":"groovy.util.ExpandoCustomizer" -}, { "name":"java.beans.PropertyVetoException" }, @@ -625,11 +513,9 @@ }, { "name":"java.io.Serializable", - "allDeclaredFields":true, "allDeclaredClasses":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.io.Writer", @@ -657,10 +543,8 @@ }, { "name":"java.lang.CharSequence", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.lang.Character" @@ -670,7 +554,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[{"name":"forName","parameterTypes":["java.lang.String","boolean","java.lang.ClassLoader"] }, {"name":"getModule","parameterTypes":[] }, {"name":"getPermittedSubclasses","parameterTypes":[] }, {"name":"isSealed","parameterTypes":[] }] + "methods":[{"name":"getPermittedSubclasses","parameterTypes":[] }, {"name":"isSealed","parameterTypes":[] }] }, { "name":"java.lang.ClassLoader", @@ -678,17 +562,13 @@ }, { "name":"java.lang.Cloneable", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.lang.Comparable", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true, "methods":[{"name":"compareTo","parameterTypes":["java.lang.Object"] }] }, { @@ -708,21 +588,7 @@ "name":"java.lang.Float" }, { - "name":"java.lang.FunctionalInterface", - "queryAllDeclaredMethods":true -}, -{ - "name":"java.lang.Integer", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"java.lang.IntegerBeanInfo" -}, -{ - "name":"java.lang.IntegerCustomizer" + "name":"java.lang.Integer" }, { "name":"java.lang.Iterable", @@ -737,23 +603,10 @@ "name":"java.lang.Math", "methods":[{"name":"floorDiv","parameterTypes":["long","long"] }, {"name":"floorMod","parameterTypes":["long","long"] }, {"name":"max","parameterTypes":["int","int"] }, {"name":"min","parameterTypes":["int","int"] }] }, -{ - "name":"java.lang.Module", - "methods":[{"name":"getDescriptor","parameterTypes":[] }] -}, { "name":"java.lang.Number", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, "methods":[{"name":"longValue","parameterTypes":[] }] }, -{ - "name":"java.lang.NumberBeanInfo" -}, -{ - "name":"java.lang.NumberCustomizer" -}, { "name":"java.lang.Object", "allDeclaredFields":true, @@ -779,10 +632,7 @@ }, { "name":"java.lang.Runnable", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.lang.RuntimePermission" @@ -792,9 +642,6 @@ }, { "name":"java.lang.String", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllDeclaredConstructors":true, "methods":[{"name":"toUpperCase","parameterTypes":[] }] }, { @@ -816,17 +663,12 @@ }, { "name":"java.lang.constant.Constable", - "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.lang.constant.ConstantDesc", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.lang.invoke.TypeDescriptor", @@ -966,10 +808,6 @@ "queryAllDeclaredMethods":true, "methods":[{"name":"clear","parameterTypes":[] }, {"name":"containsKey","parameterTypes":["java.lang.Object"] }, {"name":"containsValue","parameterTypes":["java.lang.Object"] }, {"name":"entrySet","parameterTypes":[] }, {"name":"equals","parameterTypes":["java.lang.Object"] }, {"name":"get","parameterTypes":["java.lang.Object"] }, {"name":"hashCode","parameterTypes":[] }, {"name":"isEmpty","parameterTypes":[] }, {"name":"keySet","parameterTypes":[] }, {"name":"put","parameterTypes":["java.lang.Object","java.lang.Object"] }, {"name":"putAll","parameterTypes":["java.util.Map"] }, {"name":"remove","parameterTypes":["java.lang.Object"] }, {"name":"size","parameterTypes":[] }, {"name":"values","parameterTypes":[] }] }, -{ - "name":"java.util.ArrayList", - "methods":[{"name":"","parameterTypes":["java.util.Collection"] }] -}, { "name":"java.util.Arrays", "methods":[{"name":"asList","parameterTypes":["java.lang.Object[]"] }] @@ -1002,10 +840,6 @@ "name":"java.util.Enumeration", "queryAllPublicMethods":true }, -{ - "name":"java.util.HashSet", - "methods":[{"name":"","parameterTypes":["java.util.Collection"] }] -}, { "name":"java.util.Iterator", "queryAllPublicMethods":true, @@ -1095,10 +929,7 @@ }, { "name":"java.util.concurrent.Callable", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllPublicMethods":true }, { "name":"java.util.concurrent.ForkJoinTask", @@ -1224,10 +1055,6 @@ "name":"jdk.internal.vm.annotation.IntrinsicCandidate", "queryAllDeclaredMethods":true }, -{ - "name":"jdk.internal.vm.annotation.Stable", - "queryAllDeclaredMethods":true -}, { "name":"org.apache.calcite.DataContext", "methods":[{"name":"get","parameterTypes":["java.lang.String"] }, {"name":"getQueryProvider","parameterTypes":[] }, {"name":"getRootSchema","parameterTypes":[] }] @@ -1982,6 +1809,13 @@ "queryAllDeclaredMethods":true, "queryAllPublicMethods":true }, +{ + "name":"org.apache.shardingsphere.infra.nativetest.jdbc.features.ClassBasedInlineShardingAlgorithmFixture", + "allDeclaredClasses":true, + "queryAllDeclaredMethods":true, + "queryAllPublicMethods":true, + "methods":[{"name":"","parameterTypes":[] }] +}, { "name":"org.apache.shardingsphere.infra.nativetest.jdbc.features.EncryptTest", "allDeclaredFields":true, @@ -2006,7 +1840,8 @@ "allDeclaredClasses":true, "queryAllDeclaredMethods":true, "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true + "queryAllDeclaredConstructors":true, + "methods":[{"name":"","parameterTypes":[] }, {"name":"testReadWriteSplittingInLocalTransactions","parameterTypes":[] }] }, { "name":"org.apache.shardingsphere.infra.nativetest.jdbc.features.ShadowTest", @@ -2267,7 +2102,40 @@ "name":"org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfigurationCustomizer" }, { - "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration" + "name":"org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.RandomReadQueryLoadBalanceAlgorithm", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.RoundRobinReadQueryLoadBalanceAlgorithm", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.WeightReadQueryLoadBalanceAlgorithm", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration", + "allDeclaredFields":true, + "queryAllPublicMethods":true, + "methods":[{"name":"","parameterTypes":[] }, {"name":"setDataSources","parameterTypes":["java.util.Map"] }] +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfigurationBeanInfo" +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfigurationCustomizer" +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfiguration", + "allDeclaredFields":true, + "queryAllPublicMethods":true, + "methods":[{"name":"","parameterTypes":[] }, {"name":"getLoadBalancerName","parameterTypes":[] }, {"name":"getReadDataSourceNames","parameterTypes":[] }, {"name":"getTransactionalReadQueryStrategy","parameterTypes":[] }, {"name":"getWriteDataSourceName","parameterTypes":[] }, {"name":"setReadDataSourceNames","parameterTypes":["java.util.List"] }, {"name":"setWriteDataSourceName","parameterTypes":["java.lang.String"] }] +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfigurationBeanInfo" +}, +{ + "name":"org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfigurationCustomizer" }, { "name":"org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnRegexMatchedShadowAlgorithm", @@ -2369,6 +2237,16 @@ "name":"org.apache.shardingsphere.sharding.algorithm.sharding.range.VolumeBasedRangeShardingAlgorithm", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm", + "allDeclaredClasses":true, + "queryAllPublicMethods":true +}, +{ + "name":"org.apache.shardingsphere.sharding.spi.ShardingAlgorithm", + "allDeclaredClasses":true, + "queryAllPublicMethods":true +}, { "name":"org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration", "allDeclaredFields":true, @@ -2520,10 +2398,6 @@ "name":"org.apiguardian.api.API", "queryAllPublicMethods":true }, -{ - "name":"org.codehaus.groovy.reflection.stdclasses.CachedSAMClass", - "methods":[{"name":"coerceToSAM","parameterTypes":["groovy.lang.Closure","java.lang.reflect.Method","java.lang.Class"] }] -}, { "name":"org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport", "queryAllDeclaredMethods":true @@ -2533,32 +2407,7 @@ "queryAllDeclaredMethods":true }, { - "name":"org.codehaus.groovy.runtime.GStringImpl", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"org.codehaus.groovy.runtime.GStringImplBeanInfo" -}, -{ - "name":"org.codehaus.groovy.runtime.GStringImplCustomizer" -}, -{ - "name":"org.codehaus.groovy.runtime.GeneratedClosure", - "allDeclaredFields":true, - "queryAllDeclaredMethods":true, - "queryAllPublicMethods":true, - "queryAllDeclaredConstructors":true -}, -{ - "name":"org.codehaus.groovy.runtime.GroovyCategorySupport", - "methods":[{"name":"hasCategoryInCurrentThread","parameterTypes":[] }] -}, -{ - "name":"org.codehaus.groovy.runtime.InvokerHelper", - "methods":[{"name":"getMetaClass","parameterTypes":["java.lang.Object"] }] + "name":"org.codehaus.groovy.runtime.GStringImpl" }, { "name":"org.codehaus.groovy.runtime.NullObject" @@ -2567,10 +2416,6 @@ "name":"org.codehaus.groovy.runtime.callsite.CallSite", "queryAllPublicMethods":true }, -{ - "name":"org.codehaus.groovy.runtime.dgm$560", - "methods":[{"name":"","parameterTypes":["java.lang.String","org.codehaus.groovy.reflection.CachedClass","java.lang.Class","java.lang.Class[]"] }] -}, { "name":"org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv", "methods":[{"name":"","parameterTypes":[] }] @@ -2659,14 +2504,6 @@ "name":"org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayPutAtMetaMethod", "methods":[{"name":"","parameterTypes":[] }] }, -{ - "name":"org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation", - "methods":[{"name":"castToType","parameterTypes":["java.lang.Object","java.lang.Class"] }] -}, -{ - "name":"org.codehaus.groovy.runtime.typehandling.GroovyCastException", - "methods":[{"name":"","parameterTypes":["java.lang.Object","java.lang.Class"] }] -}, { "name":"org.codehaus.groovy.vmplugin.v10.PluginDefaultGroovyMethods", "queryAllDeclaredMethods":true @@ -2675,14 +2512,6 @@ "name":"org.codehaus.groovy.vmplugin.v16.Java16", "methods":[{"name":"","parameterTypes":[] }] }, -{ - "name":"org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures", - "methods":[{"name":"invokeGroovyObjectInvoker","parameterTypes":["groovy.lang.MissingMethodException","java.lang.Object","java.lang.String","java.lang.Object[]"] }, {"name":"isNull","parameterTypes":["java.lang.Object"] }, {"name":"isSameMetaClass","parameterTypes":["groovy.lang.MetaClass","java.lang.Object"] }, {"name":"sameClass","parameterTypes":["java.lang.Class","java.lang.Object"] }, {"name":"sameClasses","parameterTypes":["java.lang.Class[]","java.lang.Object[]"] }, {"name":"setBeanProperties","parameterTypes":["groovy.lang.MetaClass","java.lang.Object","java.util.Map"] }, {"name":"unwrap","parameterTypes":["groovy.lang.GroovyRuntimeException"] }, {"name":"unwrap","parameterTypes":["java.lang.Object"] }] -}, -{ - "name":"org.codehaus.groovy.vmplugin.v8.IndyInterface", - "methods":[{"name":"fromCache","parameterTypes":["java.lang.invoke.MutableCallSite","java.lang.Class","java.lang.String","int","java.lang.Boolean","java.lang.Boolean","java.lang.Boolean","java.lang.Object","java.lang.Object[]"] }, {"name":"selectMethod","parameterTypes":["java.lang.invoke.MutableCallSite","java.lang.Class","java.lang.String","int","java.lang.Boolean","java.lang.Boolean","java.lang.Boolean","java.lang.Object","java.lang.Object[]"] }] -}, { "name":"org.codehaus.groovy.vmplugin.v8.PluginDefaultGroovyMethods", "queryAllDeclaredMethods":true @@ -2706,30 +2535,10 @@ { "name":"org.junit.internal.AssumptionViolatedException" }, -{ - "name":"org.junit.jupiter.api.Disabled", - "queryAllPublicMethods":true -}, { "name":"org.junit.jupiter.api.Test", "queryAllPublicMethods":true }, -{ - "name":"org.junit.jupiter.api.condition.DisabledIfSystemProperty", - "queryAllPublicMethods":true -}, -{ - "name":"org.junit.jupiter.api.condition.DisabledIfSystemPropertyCondition", - "methods":[{"name":"","parameterTypes":[] }] -}, -{ - "name":"org.junit.jupiter.api.condition.DisabledInNativeImage", - "queryAllPublicMethods":true -}, -{ - "name":"org.junit.jupiter.api.extension.ExtendWith", - "queryAllPublicMethods":true -}, { "name":"org.junit.platform.commons.annotation.Testable", "queryAllPublicMethods":true @@ -2795,4 +2604,4 @@ { "name":"sun.security.x509.CertificateExtensions" } -] +] \ No newline at end of file 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 58c0bb96ac32e9..304b53eda19fd6 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 @@ -84,6 +84,10 @@ "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.mode.manager.ContextManagerBuilder\\E" }, { "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository\\E" + }, { + "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.readwritesplitting.route.standard.filter.ReadDataSourcesFilter\\E" + }, { + "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm\\E" }, { "pattern":"\\QMETA-INF/services/org.apache.shardingsphere.shadow.spi.ShadowAlgorithm\\E" }, { @@ -110,12 +114,10 @@ "pattern":"\\QMETA-INF/services/org.junit.platform.engine.TestEngine\\E" }, { "pattern":"\\QMETA-INF/services/org.junit.platform.launcher.TestExecutionListener\\E" - }, { - "pattern":"\\QMETA-INF/services/org.slf4j.spi.SLF4JServiceProvider\\E" - }, { - "pattern":"\\Qlogback.xml\\E" }, { "pattern":"\\Qorg/h2/util/data.zip\\E" + }, { + "pattern":"\\Qorg/slf4j/impl/StaticLoggerBinder.class\\E" }, { "pattern":"\\Qsaffron.properties\\E" }, { @@ -124,6 +126,8 @@ "pattern":"\\Qyaml/encrypt.yaml\\E" }, { "pattern":"\\Qyaml/mask.yaml\\E" + }, { + "pattern":"\\Qyaml/readwrite-splitting.yaml\\E" }, { "pattern":"\\Qyaml/shadow.yaml\\E" }, { @@ -132,4 +136,4 @@ "pattern":"java.base:\\Qjdk/internal/icu/impl/data/icudt67b/nfkc.nrm\\E" }]}, "bundles":[] -} +} \ No newline at end of file diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/serialization-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/serialization-config.json index fc967f7f8d99a4..495d0c61486ecd 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/serialization-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/serialization-config.json @@ -8,4 +8,4 @@ ], "proxies":[ ] -} +} \ No newline at end of file diff --git a/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java b/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java index 837d5974bdbb87..01a69530e8de31 100644 --- a/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java +++ b/mode/type/standalone/repository/provider/jdbc/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/sql/JDBCRepositorySQLLoader.java @@ -82,7 +82,7 @@ public static JDBCRepositorySQL load(final String type) { } /** - * Under the GraalVM Native Image corresponding to GraalVM CE 21.0.1, although there is + * Under the GraalVM Native Image corresponding to GraalVM CE 23.0.1, although there is * `com.oracle.svm.core.jdk.resources.NativeImageResourceFileSystemProvider`, the corresponding * `com.oracle.svm.core.jdk.resources.NativeImageResourceFileSystem` does not autoload. This is mainly to align the * behavior of `ZipFileSystemProvider`, so ShardingSphere need to manually open and close the FileSystem @@ -101,15 +101,38 @@ public static JDBCRepositorySQL load(final String type) { * @see sun.nio.fs.UnixFileSystemProvider */ private static JDBCRepositorySQL loadFromDirectory(final URL url, final String type) throws URISyntaxException, IOException { - if (null != System.getProperty("org.graalvm.nativeimage.imagecode")) { - try (FileSystem ignored = FileSystems.newFileSystem(URI.create("resource:/"), Collections.singletonMap("create", "true"))) { - return loadFromDirectoryLegacy(url, type); - } - } else { + if (null == System.getProperty("org.graalvm.nativeimage.imagecode") || !"runtime".equals(System.getProperty("org.graalvm.nativeimage.imagecode"))) { return loadFromDirectoryLegacy(url, type); + } else { + try (FileSystem ignored = FileSystems.newFileSystem(URI.create("resource:/"), Collections.emptyMap())) { + return loadFromDirectoryInNativeImage(url, type); + } } } + private static JDBCRepositorySQL loadFromDirectoryInNativeImage(final URL url, final String type) throws URISyntaxException, IOException { + final JDBCRepositorySQL[] result = new JDBCRepositorySQL[1]; + Files.walkFileTree(Paths.get(url.toURI()), new SimpleFileVisitor() { + + @SneakyThrows(JAXBException.class) + @Override + public FileVisitResult visitFile(final Path file, final BasicFileAttributes attributes) throws IOException { + if (file.toString().endsWith(FILE_EXTENSION)) { + JDBCRepositorySQL provider = (JDBCRepositorySQL) JAXBContext.newInstance(JDBCRepositorySQL.class).createUnmarshaller().unmarshal(Files.newInputStream(file.toAbsolutePath())); + if (provider.isDefault()) { + result[0] = provider; + } + if (Objects.equals(provider.getType(), type)) { + result[0] = provider; + return FileVisitResult.TERMINATE; + } + } + return FileVisitResult.CONTINUE; + } + }); + return result[0]; + } + private static JDBCRepositorySQL loadFromDirectoryLegacy(final URL url, final String type) throws URISyntaxException, IOException { final JDBCRepositorySQL[] result = new JDBCRepositorySQL[1]; Files.walkFileTree(Paths.get(url.toURI()), new SimpleFileVisitor() {