Я получаю Exception in thread "main" org.yaml.snakeyaml.error.YAMLException: java.io.IOException: Stream closed
при чтении файла yaml в моем коде:
Ниже приведена структура моего проекта:
-rc
- main
- java
- MyMainClass
- resources
- application.yaml
Вот пример кода:
public class LoadYaml {
private static final Logger LOGGER = LoggerFactory.getLogger(LoadYaml.class);
public void loadYaml() {
Yaml yaml = new Yaml(new Constructor(Config.class));
InputStream inputStream = this.getClass()
.getClassLoader()
.getResourceAsStream("resources/application.yaml");
Config config = yaml.load(inputStream);
LOGGER.info(config.toString());
}
Ниже приведен мой пользовательский класс для yaml:
package org.finra.dapi.parttioncleanup;
import java.util.List;
public class Config {
private String url;
private String userName;
private String pwsKey;
private List<Tables> tables;
....getters and setters
Стек ошибок:
Exception in thread "main" org.yaml.snakeyaml.error.YAMLException: java.io.IOException: Stream closed
at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:218)
at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176)
at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:171)
at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:126)
at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1177)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:287)
at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:227)
at org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.produce(ParserImpl.java:195)
at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:148)
at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:107)
at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:139)
at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:524)
at org.yaml.snakeyaml.Yaml.load(Yaml.java:452)
at org.finra.dapi.parttioncleanup.LoadYaml.loadYaml(LoadYaml.java:23)
at org.finra.dapi.parttioncleanup.LambdaHandler.main(LambdaHandler.java:25)
Caused by: java.io.IOException: Stream closed
at java.io.PushbackInputStream.ensureOpen(PushbackInputStream.java:74)
at java.io.PushbackInputStream.read(PushbackInputStream.java:166)
at org.yaml.snakeyaml.reader.UnicodeReader.init(UnicodeReader.java:92)
at org.yaml.snakeyaml.reader.UnicodeReader.read(UnicodeReader.java:124)
at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:183)
... 15 more
Любая помощь будет оценена, спасибо