Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 165f829

Browse files
Merge pull request #1061 from oracle/empty-yaml-file
make sure that the new Yaml parser returns an empty dictionary when p...
2 parents 535f7d5 + 3916708 commit 165f829

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

‎core/src/main/java/oracle/weblogic/deploy/yaml/AbstractYamlTranslator.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ protected PyDictionary parseInternal(InputStream inputStream) throws YamlExcepti
6868
}
6969
if (docCount == 1) {
7070
firstDoc = convertJavaDataStructureToPython(docToConvert);
71+
} else if (docCount == 0) {
72+
firstDoc = getNewDictionary();
7173
}
7274
} catch (Exception ex) {
7375
YamlException pex = new YamlException("WLSDPLY-18100", ex, this.fileName, ex.getLocalizedMessage());

‎core/src/test/java/oracle/weblogic/deploy/yaml/YamlTranslatorTest.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@
3232

3333
public class YamlTranslatorTest {
3434

35+
@Test
36+
public void testEmptyModelReturnsPyDictionary() throws Exception {
37+
File yamlFile = new File("src/test/resources/yaml/empty.yaml").getAbsoluteFile();
38+
YamlTranslator yamlTranslator = new YamlTranslator(yamlFile.getAbsolutePath(), true);
39+
40+
PyDictionary actual = yamlTranslator.parse();
41+
42+
assertNotNull(actual, "empty model file should return dict");
43+
}
44+
3545
@Test
3646
public void testFlatMapScalarTypes() throws Exception {
3747
File yamlFile = new File("src/test/resources/yaml/flat-map-with-scalars.yaml").getAbsoluteFile();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright (c) 2022, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /