@SpringQueryMap does not honor @Param properties containing dash when spring-boot-starter-data-jdbc is on the classpath
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 22/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- java, spring-boot
- Ambito
- api
Direzione di ricerca
Start with the reproducer repository linked in the issue and toggle the spring-boot-starter-data-jdbc dependency in its pom to see the URL change. Then read FeignAutoConfiguration and its nested FeignJacksonConfiguration, and trace how @SpringQueryMap expands the request object's properties, including how @Param names are applied. Done means the query parameter names keep their dashes when the data-jdbc starter is present, with the reproducer test checking the generated URL.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hello there
I recently came upon a strange behavior on the current project I work on.
I want to use a FeignClient to call a search API (GET) with several query parameters.
Most of the parameters have a dash in their name, like :
- dummy-param1
- dummy-param2
So the GET url is something like : http://localhost:8080/dummyapi?dummy-param1=value1&dummy-param2=value2
Since there are multiple parameters, I want to wrap them in an object and use @SpringQueryMap.
I cannot name them with a dash in Java, so i have to map the java properties to the name the API expects with feign @Param annotation :
In my request object :
@Param("dummy-param1")
private String dummyParam1
In my FeignClient interface :
List<DummyResult> findByCriteria(@SpringQueryMap DummyCriteria request);
My feign client is in a dedicated jar with minimal dependencies : lombok, spring-boot-starter-web, spring-cloud-starter-openfeign, spring-boot-starter-test.
I also have the habit to write a small integration test with minimal Spring Boot config to easily test my FeignClient.
As is, the simple integration test works and I was confident.
However, when integrating my jar in my real application, the real call to the FeignClient does not work as expected : instead of calling the url with the expected params, the url looks likes this : http://localhost:8080/dummyapi?dummyParam1=value1&dummyParam2=value2
They basically become parameters unknown to the API.
In my case, the API does not throw any error and just ignore them, and I fetch all the data withouth any filter (fortunately it was paginated).
Since the main difference was a larger Spring context, I immediately suspected that some Spring Boot autoconfiguration was interfering with the request object serialization.
Looking into the code of FeignAutoConfiguration, I saw that it had the sub configuration FeignJacksonConfiguration related to Jackson and Spring Data.
Since it was related to serialization and since my project uses spring-boot-starter-data-jdbc, this was my first suspect.
I tried adding it to my dedicated jar, and my test then started calling the API with the wrong URL.
I used Spring Boot debug mode to look at the autoconfiguration difference between with or without the additional starter.
I could only find FeignAutoConfiguration.FeignJacksonConfiguration.
I tried disabling it using spring.cloud.openfeign.autoconfiguration.jackson.enabled=false, but it does not seem to work around the problem.
This looks like a bug to me; though I could be wrong and maybe such query params (with the dash) are not supported; and it was by chance that it worked in a smaller setup. I could also be doing something wrong.
My Project uses :
- Java 21
- Spring Boot 3.5.11
- Spring Cloud 2025.0.0 / OpenFeign 4.3.0
I understand that this version of OpenFeign is out of OSS support, so I tried it on :
- Spring Boot 4.0.9
- Spring Cloud 2025.1.4 / OpenFeign 5.0.4
The anomaly is still there.
I put up a reproducer : https://github.com/jmaniquet/openfeign-springquerymap-and-springdata-bug
The test is green by default. To show the anomaly go to the POM and uncomment the spring-boot-starter-data-jdbc part
Additional consideration
I also suspected lombok; having stumbled upon some shenaningans recently when combined with jackson.
That's why my reproducer has two variant : one with lombok @Data, one without and plein old getter/setter.
Though they both show the same behaviour, in the non-lombok variant, moving the @Param annotation on the getter actually solves the problem.
I guess that it's reflection-related.
I took a look at open issues but did not find anything similar so I opened this ticket. Not sure if it's an OpenFeign thing though. Could be Jackson or Spring Data, so maybe it's the wrong place to start. I'll reopen it elsewhere if appropriate.
Thanks for OpenFeign, its quite cool
- Lingua principale
- Java
- Stelle
- 1.3k
- Fork
- 834
- Merge medio
- 1g 15h
- PR unite (30g)
- 14
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di spring-cloud/spring-cloud-openfeign
-
question
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
spring-cloud/spring-cloud-openfeign#1392 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
FeignClientsConfiguration$MicrometerConfiguration.class cannot be opened because it does not existApertafeedback-provided
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
spring-cloud/spring-cloud-openfeign#1379 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
waiting-for-triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 57/100
spring-cloud/spring-cloud-openfeign#1344 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
waiting-for-triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
spring-cloud/spring-cloud-openfeign#1343 ·
I maintainer di solito rispondono entro 1 giorno
-
waiting-for-triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
spring-cloud/spring-cloud-openfeign#1340 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di spring-cloud/spring-cloud-openfeign
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
a2aproject/a2a-java#1275 ·
I maintainer di solito rispondono entro 1 giorno
-
module/ftp Type/Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ballerina-platform/ballerina-library#9476 ·
I maintainer di solito rispondono entro 1 giorno
-
[Feature] 为世界管理页面添加打开存档文件夹按钮Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
HMCL-dev/HMCL#7175 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
anwilli5/coin-collection-android-US#515 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
FasterXML/jackson-databind#6398 ·
I maintainer di solito rispondono entro 1 giorno