Skip to content

Add documentation/exception for required java compiler flag "parameters" #2337

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

Open
kaszuster opened this issue Mar 1, 2024 · 2 comments · May be fixed by #2874
Open

Add documentation/exception for required java compiler flag "parameters" #2337

kaszuster opened this issue Mar 1, 2024 · 2 comments · May be fixed by #2874
Labels
documentation Issues that require updates to our documentation good first issue Issues that are good for first time contributors to tackle help wanted Issues we need help with tackling

Comments

@kaszuster
Copy link

When using OpenFeign in the following way (no name attribute specified):

@RequestLine("GET /getSomething?id={id}")
String getSomething(@Param String id);

You may encounter the following exception:

... annotation was empty on param 0

This happens because @Param long catalogId is compiled as @Param long arg0. OpenFeign will then fail to read the parameter name via reflection.

To fix this, you need to pass the parameters flag to the Java compiler:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <parameters>true</parameters>
    </configuration>
</plugin>

After hours of research and debugging I have found this solution. Just now I found a little hint in your documentation: (if the code was compiled with -parameters flag). I would like to see that more visible or even in the exception..

@kdavisk6 kdavisk6 added help wanted Issues we need help with tackling documentation Issues that require updates to our documentation good first issue Issues that are good for first time contributors to tackle labels Sep 11, 2024
@kdavisk6
Copy link
Member

Thanks for finding this. Open to pull requests to update our documentation.

@rojae
Copy link

rojae commented Apr 30, 2025

Do you mind if I take care of it?

I think adding a clear message at the code level would be more helpful than updating the documentation in this case.
It could save developers a lot of time by directly pointing out the cause of the issue.
I’d like to propose a simple change to improve the exception message.

And I actually spent quite a bit of time trying to figure this out myself, so I believe a better message would really help others avoid the same confusion.

If you feel this approach isn't appropriate, I’m happy to update the documentation instead.
Just let me know what you prefer.

rojae added a commit to rojae/feign that referenced this issue Apr 30, 2025
- Added a helpful hint in the exception message when @param is missing a value and parameter name can't be resolved.
- Added a unit test to cover this case.

Files affected:
- Contract.java
- DefaultContractTest.java

Fixes OpenFeign#2337
rojae added a commit to rojae/feign that referenced this issue Apr 30, 2025
- Added a helpful hint in the exception message when @param is missing a value and parameter name can't be resolved.
- Added a unit test to cover this case.

Files affected:
- Contract.java
- DefaultContractTest.java

Fixes OpenFeign#2337
@rojae rojae linked a pull request Apr 30, 2025 that will close this issue
rojae added a commit to rojae/feign that referenced this issue May 7, 2025
- Added a helpful hint in the exception message when @param is missing a value and parameter name can't be resolved.
- Added a unit test to cover this case.
     - The test is skipped if the code was compiled with the `-parameters` compiler flag.

Files affected:
- Contract.java
- DefaultContractTest.java

Fixes OpenFeign#2337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues that require updates to our documentation good first issue Issues that are good for first time contributors to tackle help wanted Issues we need help with tackling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants