redhat-developer / redhat-developer/vscode-java
Spring "PathVariable annotation was empty on param" method mapping
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2.3k
- Forks
- 546
- Merge medio
- 20 h 1 min
- PR fusionados (30 d)
- 11
Descripción
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)
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Reproduce el fallo con la configuración descrita de Spring Boot y FeignClient en el VS Code Java test runner y, después, inspecciona cómo la extensión configura la generación de parámetros de métodos del compilador JDT en comparación con Gradle e IntelliJ. Se considera terminado cuando @PathVariable String urlId funciona en el VS Code runner sin un workaround de settings.pref por dispositivo, con cobertura de regresión si se identifica el punto de entrada de prueba relevante.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java, spring, vscode
- Área
- developer-experience, tooling
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100