Skip to content

Commit

Permalink
Don't validate completely empty yaml subdocs in application.yml
Browse files Browse the repository at this point in the history
See #711
  • Loading branch information
kdvolder committed Jun 21, 2022
1 parent 24667d6 commit 7eccab1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.springframework.ide.vscode.commons.yaml.ast.YamlFileAST;
import org.springframework.ide.vscode.commons.yaml.path.YamlPath;
import org.springframework.ide.vscode.commons.yaml.reconcile.YamlASTReconciler;
import org.springframework.ide.vscode.commons.yaml.util.YamlUtil;
import org.yaml.snakeyaml.nodes.MappingNode;
import org.yaml.snakeyaml.nodes.Node;
import org.yaml.snakeyaml.nodes.NodeId;
Expand Down Expand Up @@ -95,7 +96,12 @@ protected void reconcile(YamlFileAST root, IndexNavigator nav) {
List<Node> nodes = root.getNodes();
if (nodes!=null && !nodes.isEmpty()) {
for (Node node : nodes) {
reconcile(root, node, nav);
if (!"".equals(NodeUtil.asScalar(node))) {
//^^^ ignore completely empty yaml (sub)documents. Checking them results in
//spurious errors/warnings.
//See https://github.com/spring-projects/sts4/issues/711
reconcile(root, node, nav);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@ public void cleanups() {
}

////////////////////////////////////////////////////////////////////////////////////////

@Test public void test_GH_711_error_on_extra_empty_yaml_document() throws Exception {
//https://github.com/spring-projects/sts4/issues/711
defaultTestData();
Editor editor = newEditor(
"spring:\n" +
" application:\n" +
" name: demo\n" +
"---\n" +
"spring:\n" +
" profiles:\n" +
" active: dev\n" +
"services:\n" +
" common:\n" +
" url: https://getguid.azurewebsites.net\n" +
"---\n"
);
editor.assertProblems(
"services|Unknown"
);
}

@Test public void test_GH_615_deprecated_spring_profiles() throws Exception {
IJavaProject p = createPredefinedMavenProject("empty-boot-2.4.4-app");
Expand Down

0 comments on commit 7eccab1

Please sign in to comment.