spring-boot-migrator icon indicating copy to clipboard operation
spring-boot-migrator copied to clipboard

Log and proceed when resources under test have syntax errors

Open ashakirin opened this issue 3 years ago • 0 comments

What needs to be done

Resources in src/test/resources that are not parseable should be ignored by the RewriteMavenParser and a message under INFO should be logged

Why it needs to be dine

Scan of cwa-server throws exception on yaml file under src/test/resources with incorrect syntax

Scanning Open source Corona Application https://github.com/corona-warn-app/cwa-server The project has yaml files with incorrect syntax in junit tests resources. SBM throws exception during scanning:

17:45:51.928 [main] ERROR o.s.s.o.RewriteExecutionContext - Exception occured!
java.lang.IllegalStateException: /Users/ashakirin/DevResources/SpringBootMigrator/cwa-server/services/distribution/src/test/resources/configtests/app-config_broken_syntax.yaml mapping values are not allowed here
 in 'reader', line 4, column 21:
      risk-score-classes: !include risk-score-class_ok.y ... 
                        ^

	at org.openrewrite.yaml.YamlParser.lambda$parseInputs$0(YamlParser.java:78)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at org.openrewrite.yaml.YamlParser.parseInputs(YamlParser.java:92)
	at org.springframework.sbm.project.parser.ResourceParser.lambda$parse$6(ResourceParser.java:118)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at org.springframework.sbm.project.parser.ResourceParser.parse(ResourceParser.java:121)
	at org.springframework.sbm.project.parser.MavenProjectParser.parse(MavenProjectParser.java:179)
	at org.springframework.sbm.project.parser.ProjectContextInitializer.initProjectContext(ProjectContextInitializer.java:54)
	at org.springframework.sbm.engine.commands.ScanCommand.execute(ScanCommand.java:57)
	at org.springframework.sbm.shell.ScanShellCommand.scan(ScanShellCommand.java:70)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.shell.command.invocation.InvocableShellMethod.doInvoke(InvocableShellMethod.java:306)
	at org.springframework.shell.command.invocation.InvocableShellMethod.invoke(InvocableShellMethod.java:232)
	at org.springframework.shell.command.CommandExecution$DefaultCommandExecution.evaluate(CommandExecution.java:158)
	at org.springframework.shell.Shell.evaluate(Shell.java:208)
	at org.springframework.shell.Shell.run(Shell.java:140)
	at org.springframework.shell.jline.InteractiveShellRunner.run(InteractiveShellRunner.java:73)
	at org.springframework.shell.DefaultShellApplicationRunner.run(DefaultShellApplicationRunner.java:65)
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:762)
	at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:752)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
	at org.springframework.sbm.SpringShellApplication.main(SpringShellApplication.java:27)

ashakirin avatar Sep 16 '22 15:09 ashakirin