Skip to content

Naming of @Selector params for custom Actuator endpoints requires class file method parameter embedding #11010

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

Closed
shabino opened this issue Nov 14, 2017 · 3 comments
Labels
status: duplicate A duplicate of another issue

Comments

@shabino
Copy link

shabino commented Nov 14, 2017

Edit: This is based on testing against 2.0.0.M6.

Names of Actuator endpoint @Selector parameters are set based on their associated method parameter names. For this to work properly, endpoint classes must be compiled with these parameter names embedded (-parameters javac param, <parameters>true</parameters> in Maven, etc.). This happens by default if one's Spring Boot Maven project is defined with spring-boot-starter-parent as its parent. But, if one isn't using this Maven configuration, @Selector params end-up with names like arg0, and the cause is non-obvious.

Please consider:

  1. Noting in the documentation for custom Actuator endpoints that embedded parameter names are required for custom naming.

  2. Adding a name parameter to @Selector that allows one to explicitly specify/override the parameter name.

Note that I haven't looked into whether a default Gradle, etc. Spring Boot set-up results in compilation with embedded parameter names.

Also, even if one has his POM configured to compile with embedded parameter names, separate IDE configuration likely is required to turn this on when allowing an IDE to compile instead:

https://stackoverflow.com/questions/39217830/how-to-use-parameters-javac-option-in-intellij

@snicoll
Copy link
Member

snicoll commented Nov 14, 2017

@selector params end-up with names like arg0, and the cause is non-obvious.

That's not the case anymore. You'll get an exception instead now. We still need to finalize the documentation of that infrastructure so we'll take that into account.

That name offer is a bit more complicated than that: we want to ease the programming model and anything that's not a @Selector is a request parameter (for GET) or an attribute of the body. Relying on parameter names is quite handy in that situation.

@snicoll snicoll added priority: normal type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 14, 2017
@snicoll snicoll modified the milestones: 2.0.0.M7, 2.0.0.RC1 Nov 14, 2017
@shabino
Copy link
Author

shabino commented Nov 14, 2017

An actionable error message ought to be good enough. And, having the ability to specify request params would be great. I ended up creating two top-level endpoints as a workaround. In my usecase, I have Foo objects that can be looked-up by two different kinds of keys.

@snicoll
Copy link
Member

snicoll commented Nov 24, 2017

Duplicates #10001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants