Closed lt-dh closed 6 months ago
Can you provide a reproducible git containing unit tests? The log on 5.4.2-SNAPSHOT seems to be a YAML configuration writing problem. Reference https://github.com/apache/shardingsphere/tree/master/test%2Fnative%2Fsrc%2Ftest%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Ftest%2Fnatived%2Fjdbc%2Fdatabases
Both testcontainers-java and h2database are available.
- Can you provide a reproducible git containing unit tests? The log on 5.4.2-SNAPSHOT seems to be a YAML configuration writing problem. Reference https://github.com/apache/shardingsphere/tree/master/test%2Fnative%2Fsrc%2Ftest%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Ftest%2Fnatived%2Fjdbc%2Fdatabases
- Both testcontainers-java and h2database are available.
I found when calling ClasspathResourceDirectoryReader.read() , it will read to com/alibaba/fastjson2 / fastjson2/2.0.47 / fastjson2-2.0.47. Jar! /schema/ and the static code in SystemSchemaManager:
static {
List<String> resourceNames;
try (Stream<String> resourceNameStream = ClasspathResourceDirectoryReader.read("schema")) {
resourceNames = resourceNameStream.collect(Collectors.toList());
}
DATABASE_TYPE_SCHEMA_TABLE_MAP = resourceNames.stream().map(resourceName -> resourceName.split("/")).collect(Collectors.groupingBy(path -> path[1], CaseInsensitiveMap::new,
Collectors.groupingBy(path -> path[2], CaseInsensitiveMap::new, Collectors.mapping(path -> StringUtils.removeEnd(path[3], ".yaml"),
Collectors.toCollection(CaseInsensitiveSet::new)))));
DATABASE_TYPE_SCHEMA_RESOURCE_MAP = resourceNames.stream().map(resourceName -> resourceName.split("/")).collect(Collectors.groupingBy(path -> path[1], CaseInsensitiveMap::new,
Collectors.groupingBy(path -> path[2], CaseInsensitiveMap::new, Collectors.mapping(path -> String.join("/", path),
Collectors.toCollection(CaseInsensitiveSet::new)))));
}
resourceNames will contations ["schema/2020-12.json","schema/draft-04.json"].
I think that's the problem,.Whether filter() should be added to the code. and what do you suggest I do to use sharding.
This is actually because https://github.com/apache/shardingsphere/blob/0ab150a1e435ce58792311ff0a0d3a878d6b3817/infra/util/src/main/java/org/apache/shardingsphere/infra/util/directory/ClasspathResourceDirectoryReader.java is using Thread.currentThread().getContextClassLoader()
, rather than the class's own ClassLoader. This caused it to be incorrectly parsed to the fastjson2 folder.
I believe this will have to require you to temporarily remove your use of fastjson2.
@iamhucong It looks like this class was refactored by you, should the fix for this be put into the 5.5.0-release branch? Or just keep it in the master branch?
sdk install java 21.0.2-graalce
sdk use java 21.0.2-graalce
git clone git@github.com:apache/shardingsphere.git
cd ./shardingsphere/
git reset --hard 3b88c08e726119d955b6a6d3809072e836c5ab3d
./mvnw clean install -Prelease -T1C -DskipTests -Djacoco.skip=true -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true
@linghengqian Thank you for your answer
all my config:
yaml is as follows:
I don't want to use version 1.33 of snackyaml
I tried using the java api to config but it didn't work,same error as above
I tried this,and i got shardingsphere-jdbc:5.4.2-SNAPSHOT :
I tried again,yaml configuration is still used:
I got this error:
What should I do next .Somebody help me .thank you.