Skip to content

Log and proceed when resources under test have syntax errors #399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ashakirin opened this issue Sep 16, 2022 · 1 comment · Fixed by #568
Closed

Log and proceed when resources under test have syntax errors #399

ashakirin opened this issue Sep 16, 2022 · 1 comment · Fixed by #568
Labels
in: sbm-core type: enhancement New feature or request
Milestone

Comments

@ashakirin
Copy link
Contributor

ashakirin commented Sep 16, 2022

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 ashakirin changed the title Scan throw exception on yaml file with incorrect syntax Scan of cwa-server throws exception on yaml file with incorrect syntax Sep 16, 2022
@fabapp2 fabapp2 added 3.0.0 Spring Boot 3.0.0 upgrade-boot:migration type: enhancement New feature or request labels Sep 26, 2022
@fabapp2 fabapp2 added this to the v0.13.0 milestone Sep 26, 2022
@fabapp2 fabapp2 changed the title Scan of cwa-server throws exception on yaml file with incorrect syntax Log and proceed when resources under test have syntax errors Oct 18, 2022
@fabapp2 fabapp2 added in: sbm-core and removed upgrade:boot 3.0.0 Spring Boot 3.0.0 labels Oct 18, 2022
@fabapp2
Copy link
Contributor

fabapp2 commented Nov 22, 2022

The exception is printed but does not affect other valid resources.
We keep it as is and live with the printed exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: sbm-core type: enhancement New feature or request
Projects
None yet
2 participants