Skip to content

Commit

Permalink
ignore unknown parameters in yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
EinsamHauer committed Jan 22, 2019
1 parent 1818867 commit 3664dab
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/net/iponweb/disthene/reader/DistheneReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.apache.commons.cli.*;
import org.apache.log4j.Logger;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.representer.Representer;
import sun.misc.Signal;
import sun.misc.SignalHandler;

Expand Down Expand Up @@ -48,14 +49,21 @@ public class DistheneReader {
private StatsService statsService;
private ThrottlingService throttlingService;

private static Yaml yaml;
static {
Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);
yaml = new Yaml(representer);
}


private DistheneReader(String configLocation, String throttlingConfigLocation) {
this.configLocation = configLocation;
this.throttlingConfigLocation = throttlingConfigLocation;
}

private void run() {
try {
Yaml yaml = new Yaml();
InputStream in = Files.newInputStream(Paths.get(configLocation));
DistheneReaderConfiguration distheneReaderConfiguration = yaml.loadAs(in, DistheneReaderConfiguration.class);
in.close();
Expand Down Expand Up @@ -185,7 +193,6 @@ public void handle(Signal signal) {
ThrottlingConfiguration throttlingConfiguration;
File file = new File(throttlingConfigLocation);
if(file.exists() && !file.isDirectory()) {
Yaml yaml = new Yaml();
logger.info("Loading throttling configuration");
InputStream in = Files.newInputStream(Paths.get(throttlingConfigLocation));
throttlingConfiguration = yaml.loadAs(in, ThrottlingConfiguration.class);
Expand Down

0 comments on commit 3664dab

Please sign in to comment.