@SpringQueryMap does not honor @Param properties containing dash when spring-boot-starter-data-jdbc is on the classpath

オープン
#1,452 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
22/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java, spring-boot
領域
api

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

waiting-for-triage

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

主要言語
Java
スター
1.3k
フォーク
834
平均マージ
1日 15時間
マージ済み PR(30日)
14

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

spring-cloud/spring-cloud-openfeign のほかの issue

spring-cloud/spring-cloud-openfeign の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。