Skip to content
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

Gateway MVC: Retry filter not supported with YAML configuration #3172

Closed
ah1508 opened this issue Dec 10, 2023 · 4 comments
Closed

Gateway MVC: Retry filter not supported with YAML configuration #3172

ah1508 opened this issue Dec 10, 2023 · 4 comments
Labels
Milestone

Comments

@ah1508
Copy link

ah1508 commented Dec 10, 2023

Describe the bug

Retry filter usage as described in the documentation (https://docs.spring.io/spring-cloud-gateway/reference/spring-cloud-gateway-server-mvc/filters/retry.html) does not work with spring-gateway-server-mvc 4.1 (spring-retry is in the classpath).

spring.cloud.gateway.mvc.routes:
    - id: foo-routing
      predicates:
        - Path=/foo/**
      uri: http://foo-api
      filters:
        - name: Retry
          args:
            retries: 3
            series: SERVER_ERROR
            methods: GET,POST

Error message: Unable to find operation interface org.springframework.web.servlet.function.HandlerFilterFunction for retry with args {retries=3, series=SERVER_ERROR, methods=GET,POST}

Last lines of the stacktrace

Caused by: java.lang.IllegalArgumentException: Unable to find operation interface org.springframework.web.servlet.function.HandlerFilterFunction for retry with args {retries=3, series=SERVER_ERROR, methods=GET,POST}
	at org.springframework.cloud.gateway.server.mvc.config.GatewayMvcPropertiesBeanDefinitionRegistrar.translate(GatewayMvcPropertiesBeanDefinitionRegistrar.java:252) ~[spring-cloud-gateway-server-mvc-4.1.0.jar:4.1.0]
	at org.springframework.cloud.gateway.server.mvc.config.GatewayMvcPropertiesBeanDefinitionRegistrar.lambda$getRouterFunction$6(GatewayMvcPropertiesBeanDefinitionRegistrar.java:232) ~[spring-cloud-gateway-server-mvc-4.1.0.jar:4.1.0]
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596) ~[na:na]

The translate methods receives a MultiValueMap<String, OperationMethod> operations that contains 29 items, retry is not one of them:

Screenshot from 2023-12-10 12-05-01

@kristiyandimov19
Copy link

I have a similar issue, for me when creating a custom filter it works fine when using it as a @bean but when i try to configure it in application.yml it doesn't get picked up at all

@spencergibb
Copy link
Member

@kristiyandimov19 yes, I need to document how to make custom filters and predicates available to config

Add @Shortcut to the static method

and then create a FilterSupplier

class FilterSupplier implements org.springframework.cloud.gateway.server.mvc.filter.FilterSupplier {

and add it to spring.factories

org.springframework.cloud.gateway.server.mvc.filter.FilterFunctions.FilterSupplier

@kstueve1
Copy link

so I have to modify spring.factories. what happened to dependency injection

@spencergibb
Copy link
Member

There's an enhancement request open to make it easier for developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants