Skip to content
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

No longer able to override the toString() in HandlerMethod from 6.1.3 #32184

Closed
mauriciogeneroso opened this issue Feb 1, 2024 · 3 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Milestone

Comments

@mauriciogeneroso
Copy link

mauriciogeneroso commented Feb 1, 2024

Affects: 6.1.3


Spring actuator has a WebMvcEndpointHandlerMethod that extends and overrides the toString() from HandlerMethod here.

After the change made on the issue #32007, (this commit), the toString() is no longer used because the HandlerMethod is wrapped into another instance of HandlerMethod, In this block of code:

  // Enable method validation, if applicable
  handlerMethod = handlerMethod.createWithValidateFlags();

And this one:

  /**
  * Re-create the HandlerMethod and initialise
  * {@link #shouldValidateArguments()} and {@link #shouldValidateReturnValue()}.
  * @since 6.1.3
  */
  public HandlerMethod createWithValidateFlags() {
     return new HandlerMethod(this, null, true);
  }

So, I found the issue because in spring-open-api it is no longer able to generate the correct name of the endpoints from actuator /health, /info, /metrics, etc.. due to code is calling the wrong toString() method.

Expected

The field validations implemented in the issue #32007 should not force the override of the toString() wrapping its subclasses back into HandlerMethod.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 1, 2024
@jhoeller jhoeller added in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 1, 2024
@jhoeller jhoeller added this to the 6.1.4 milestone Feb 1, 2024
@jhoeller jhoeller self-assigned this Feb 1, 2024
@jhoeller
Copy link
Contributor

jhoeller commented Feb 1, 2024

We could preserve the overridden toString result in the HandlerMethod copy constructor, setting the new description to handlerMethod.toString() instead of handlerMethod.description. I'll change this for the upcoming 6.1.4 snapshot, feel free to give it a try: https://ci.spring.io/teams/spring-framework/pipelines/spring-framework-6.1.x/jobs/build/builds/1383

@mauriciogeneroso
Copy link
Author

@jhoeller tested with 6.1.4-SNAPSHOT and it is fixed.

I'll wait for the release.
Thank you for fixing it.

@jhoeller
Copy link
Contributor

jhoeller commented Feb 1, 2024

Thanks for double-checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants