Skip to content

StubRunner should fail if stubrunner.stubsPerConsumer=true and no stubs are found #2114

Closed
@jakub-bochenski

Description

@jakub-bochenski

Describe the bug
If I run the "normal" mode it fails if no stubs are found:

2024-05-23T15:57:37.439Z  WARN 6 --- [stubrunner] [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchStubRunnerBeanPostProcessor' defined in org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration: Unsatisfied dependency expressed through method 'batchStubRunnerBeanPostProcessor' parameter 0: Error creating bean with name 'batchStubRunner' defined in org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration: Failed to instantiate [org.springframework.cloud.contract.stubrunner.BatchStubRunner]: Factory method 'batchStubRunner' threw exception with message: No stubs or contracts were found for [com.zuvoo.contracts:permission-service:+:stubs] and the switch to fail on no stubs was set.

If I enable stubrunner.stubsPerConsumer=true the StubRunner will run even if no stubs are found for a consumer.

Sample

Running Spring Cloud Contract Stub Runner
Please wait for the dependencies to be downloaded...
SLF4J(I): Connected with provider of type [ch.qos.logback.classic.spi.LogbackServiceProvider]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.0)

2024-05-23T16:29:47.808Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.s.server.StubRunnerBoot          : Starting StubRunnerBoot v4.1.1 using Java 17.0.1 with PID 6 (/home/scc/stub-runner-boot.jar started by scc in /home/scc)
2024-05-23T16:29:47.810Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.s.server.StubRunnerBoot          : No active profile set, falling back to 1 default profile: "default"
2024-05-23T16:29:48.372Z  WARN 6 --- [stubrunner] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration' of type [org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [batchStubRunnerBeanPostProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead.
2024-05-23T16:29:48.384Z  WARN 6 --- [stubrunner] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'stubrunner-org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties' of type [org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [batchStubRunnerBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-05-23T16:29:48.388Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.s.AetherStubDownloaderBuilder    : Will download stubs and contracts via Aether
2024-05-23T16:29:48.399Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.stubrunner.AetherStubDownloader  : Remote repos not passed but the switch to work offline was set. Stubs will be used from your local Maven repository.
2024-05-23T16:29:48.444Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.stubrunner.AetherStubDownloader  : Desired version is [+] - will try to resolve the latest version
2024-05-23T16:29:48.452Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.stubrunner.AetherStubDownloader  : Resolved version is [1.0.0-SNAPSHOT]
2024-05-23T16:29:48.454Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.stubrunner.AetherStubDownloader  : Resolved artifact [com.zuvoo.contracts:permission-service:jar:stubs:1.0.0-SNAPSHOT] to /home/scc/.m2/repository/com/zuvoo/contracts/permission-service/1.0.0-SNAPSHOT/permission-service-1.0.0-SNAPSHOT-stubs.jar
2024-05-23T16:29:48.455Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.stubrunner.AetherStubDownloader  : Unpacking stub from JAR [URI: file:/home/scc/.m2/repository/com/zuvoo/contracts/permission-service/1.0.0-SNAPSHOT/permission-service-1.0.0-SNAPSHOT-stubs.jar]
2024-05-23T16:29:48.458Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.stubrunner.AetherStubDownloader  : Unpacked file to [/tmp/contracts-1716481788454-0]
2024-05-23T16:29:48.808Z  INFO 6 --- [stubrunner] [           main] o.s.c.contract.stubrunner.StubServer     : Started stub server for project [com.zuvoo.contracts:permission-service:1.0.0-SNAPSHOT:stubs] on port -1 with [0] mappings
2024-05-23T16:29:48.808Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.stubrunner.StubRunnerExecutor    : All stubs are now running RunningStubs [namesAndPorts={com.zuvoo.contracts:permission-service:1.0.0-SNAPSHOT:stubs=-1}]
2024-05-23T16:29:48.808Z  WARN 6 --- [stubrunner] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'batchStubRunner' of type [org.springframework.cloud.contract.stubrunner.BatchStubRunner] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [batchStubRunnerBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-05-23T16:29:48.916Z  INFO 6 --- [stubrunner] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8750 (http)
2024-05-23T16:29:48.921Z  INFO 6 --- [stubrunner] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-05-23T16:29:48.921Z  INFO 6 --- [stubrunner] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.16]
2024-05-23T16:29:48.931Z  INFO 6 --- [stubrunner] [           main] o.apache.catalina.loader.WebappLoader    : Unknown class loader [jdk.internal.loader.ClassLoaders$PlatformClassLoader@1a0f7617] of class [class jdk.internal.loader.ClassLoaders$PlatformClassLoader]
2024-05-23T16:29:48.957Z  INFO 6 --- [stubrunner] [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-05-23T16:29:48.958Z  INFO 6 --- [stubrunner] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 974 ms
2024-05-23T16:29:49.152Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.v.m.i.ContractVerifierMessaging  : The message verifier sender implementation is of type [class org.springframework.cloud.contract.verifier.messaging.noop.NoOpStubMessages]
2024-05-23T16:29:49.152Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.v.m.i.ContractVerifierMessaging  : The message verifier receiver implementation is of type [class org.springframework.cloud.contract.verifier.messaging.noop.NoOpStubMessages]
2024-05-23T16:29:49.171Z  INFO 6 --- [stubrunner] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8750 (http) with context path ''
2024-05-23T16:29:49.185Z  INFO 6 --- [stubrunner] [           main] o.s.c.c.s.server.StubRunnerBoot          : Started StubRunnerBoot in 1.692 seconds (process running for 3.183)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions