Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
EricGao888 committed May 13, 2024
1 parent 614620d commit 7478774
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@

package org.apache.dolphinscheduler.common.utils;

import lombok.extern.slf4j.Slf4j;

import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.constructor.Constructor;

/**
* Whitelist constructor implementation for YAML snake.
* Copied from Apache ShardingSphere and Apache Skywalking.
*/
@Slf4j
public final class ClassFilterConstructor extends Constructor {

private final Class<?>[] acceptClasses;
Expand All @@ -38,6 +41,7 @@ public ClassFilterConstructor(final Class<?>[] acceptClasses) {
protected Class<?> getClassForName(final String name) throws ClassNotFoundException {
for (Class<? extends Object> each : acceptClasses) {
if (name.equals(each.getName())) {
log.info("name - {} : class - {}", name, super.getClassForName(name));
return super.getClassForName(name);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class HttpTaskDefinitionParser implements TaskDefinitionParser<HttpLoopTa

protected @NonNull LoopTaskYamlDefinition parseYamlConfigFile(@NonNull String yamlConfigFile) throws IOException {
try (FileReader fileReader = new FileReader(yamlConfigFile)) {
return new Yaml(new ClassFilterConstructor(new Class[]{LoopTaskYamlDefinition.class}))
return new Yaml(new ClassFilterConstructor(new Class[]{LoopTaskYamlDefinition.class, LoopTaskYamlDefinition.LoopTaskSubmitMethodYamlDefinition.class}))
.loadAs(fileReader, LoopTaskYamlDefinition.class);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public void parseYamlConfigFile() throws IOException {
Assertions.assertNotNull(loopTaskYamlDefinition.getService());
LoopTaskYamlDefinition.LoopTaskServiceYamlDefinition service = loopTaskYamlDefinition.getService();
Assertions.assertEquals("MockService", service.getName());
Assertions.assertEquals("Http", service.getType());
Assertions.assertEquals("/api/v1/submit", service.getApi().getSubmit().getUrl());
Assertions.assertNotNull(service.getApi());
}

Expand Down

0 comments on commit 7478774

Please sign in to comment.