Skip to content

Commit

Permalink
Revert "Change yaml parser to yamlbeans (#995)"
Browse files Browse the repository at this point in the history
This reverts commit 1a28741.
  • Loading branch information
imbyungjun committed May 14, 2024
1 parent a394fd1 commit 5d792b2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 106 deletions.
2 changes: 1 addition & 1 deletion ngrinder-controller/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ dependencies {
implementation (group: "jaxen", name: "jaxen", version: "1.1.4")
implementation (group: "com.beust", name: "jcommander", version: "1.32")
implementation (group: "org.pf4j", name: "pf4j", version: "3.0.1")
implementation (group: "com.esotericsoftware.yamlbeans", name: "yamlbeans", version: "1.17")
implementation (group: "org.yaml", name: "snakeyaml", version: "1.25")
implementation (group: "commons-collections", name: "commons-collections", version: "3.2.1")
implementation (group: "org.reflections", name: "reflections", version: "0.9.9")
implementation (group: "com.hazelcast", name: "hazelcast", version: hazelcast_version)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.ngrinder.script.service;

import com.esotericsoftware.yamlbeans.YamlReader;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -27,6 +26,7 @@
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.BasicAuthenticationManager;
import org.tmatesoft.svn.core.wc.*;
import org.yaml.snakeyaml.Yaml;

import java.io.File;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -280,24 +280,23 @@ public Set<GitHubConfig> getAllGitHubConfig(User user) throws FileNotFoundExcept

private Set<GitHubConfig> getAllGithubConfig(FileEntry gitConfigYaml) {
Set<GitHubConfig> gitHubConfig = new HashSet<>();
try (YamlReader reader = new YamlReader(gitConfigYaml.getContent())) {
Map<String, Object> gitConfigMap = cast(reader.read());
while (gitConfigMap != null) {
gitConfigMap.put("revision", gitConfigYaml.getRevision());
GitHubConfig config = objectMapper.convertValue(gitConfigMap, GitHubConfig.class);

if (gitHubConfig.contains(config)) {
throw new InvalidGitHubConfigurationException("GitHub configuration '"
+ config.getName() + "' is duplicated.\nPlease check your .gitconfig.yml");
}

gitHubConfig.add(config);
// Yaml is not thread safe. so create it every time.
Yaml yaml = new Yaml();
Iterable<Map<String, Object>> gitConfigs = cast(yaml.loadAll(gitConfigYaml.getContent()));
for (Map<String, Object> configMap : gitConfigs) {
if (configMap == null) {
continue;
}
configMap.put("revision", gitConfigYaml.getRevision());
GitHubConfig config = objectMapper.convertValue(configMap, GitHubConfig.class);

gitConfigMap = cast(reader.read());
if (gitHubConfig.contains(config)) {
throw new InvalidGitHubConfigurationException("GitHub configuration '"
+ config.getName() + "' is duplicated.\nPlease check your .gitconfig.yml");
}
} catch (IOException e) {
throw new InvalidGitHubConfigurationException("Fail to read GitHub configuration.", e);
}

gitHubConfig.add(config);
}
return gitHubConfig;
}

Expand Down

This file was deleted.

0 comments on commit 5d792b2

Please sign in to comment.