redhat-developer / redhat-developer/vscode-java
Spring "PathVariable annotation was empty on param" method mapping
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 2.3k
- フォーク
- 546
- 平均マージ
- 20時間 1分
- マージ済み PR(30日)
- 11
説明
I'm trying to test a FeignClient where I've defined a PathVariable using a @PathVariable String urlId but I'm receiving a PathVariable annotation was empty on param 0 when I attempt to run my tests. It works via a gradlew test but not in the VS Code test runner. I can resolve this by explicitly mapping @PathVariable(value = "urlId") String urlId but the documentation defines that as an optional field (https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/annotation/PathVariable.html).
I believe this is something related to the compiler, because gradlew test and IntelliJ can run the tests without the explicit mapping, but it only fails with the error in the VS Code test extension. Reading the spring docs it calls out in the input mapping that if it's compiled with the -parameters flag it will map the input to the method's parameters (https://docs.spring.io/spring-boot/reference/actuator/endpoints.html#actuator.endpoints.implementing-custom.input). I was able to successfully validate this in VS Code by going to the Java > Settings: Url and pointing it to a new settings.pref file I created that only contains the line org.eclipse.jdt.core.compiler.codegen.methodParameters=generate, which allowed the compiler to map without the explicit (value = "urlId") on the annotation. I'm not a huge fan of this approach however, because I'm positive I'm going to forget this every time I setup a new device, so I was wondering if this constituted an issue that could be rolled into the extension so this was supported without having to create a custom settings file any time I need to test a spring project with feign client.
For additional system details I'm running spring boot 3.4.1, with a gradle build it, on Java 21.0.6 (Amazon Corretto 21) on the Java Language Support extension version 1.41.0 (temporarily downgraded from 1.41.1 due to https://github.com/redhat-developer/vscode-java/issues/4002)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
説明されている Spring Boot と FeignClient のセットアップで VS Code Java test runner 上の失敗を再現し、その後、拡張機能が Gradle および IntelliJ と比較して JDT compiler のメソッドパラメーター生成をどのように設定しているかを調査する。@PathVariable String urlId がデバイスごとの settings.pref workaround なしで VS Code runner で動作し、関連するテストエントリーポイントが特定できた場合に回帰テストのカバレッジがあることを完了条件とする。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java, spring, vscode
- 領域
- developer-experience, tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100