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

Document need for -parameters flag in exception messages #31675

Closed
sbrannen opened this issue Nov 24, 2023 · 4 comments
Closed

Document need for -parameters flag in exception messages #31675

sbrannen opened this issue Nov 24, 2023 · 4 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Nov 24, 2023

Overview

Since -parameters is required for certain use cases starting with Spring Framework 6.1, we should revise related exception messages to explicitly mention the solution.

For example, a Spring MVC @Controller handler method with a @PathVariable String client parameter declaration may fail with an exception similar to the following.

java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not found in class file either.

To improve diagnostics, we should add something along the lines of Ensure that the compiler uses the -parameters flag. to the end of that exception message.

Related Issues

@sbrannen sbrannen added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Nov 24, 2023
@sbrannen sbrannen self-assigned this Nov 24, 2023
@sbrannen sbrannen added this to the 6.1.2 milestone Nov 24, 2023
@philwebb
Copy link
Member

@sbrannen @bclozel Any thoughts about introducing a dedicated exception type? We could then have a failure analyzer in Spring Boot.

@sbrannen
Copy link
Member Author

Reopening to improve exception message in CacheAspectSupport.generateKey(CacheOperationContext, Object).

@sbrannen sbrannen reopened this Nov 30, 2023
@sbrannen
Copy link
Member Author

sbrannen commented Nov 30, 2023

Any thoughts about introducing a dedicated exception type?

That's an interesting idea.

For some use cases (e.g., mvc controller handler methods, and cache key generation) it would be relatively straightforward; however, for other uses (e.g., SpEL expressions, parameter named used as fallback qualifier for dependency injection by type) it may not be as straightforward to pin down what the trigger would be for such an exception.

In any case, we'll discuss it amongst the team.

@sbrannen
Copy link
Member Author

sbrannen commented Dec 6, 2023

Note to maintainers

If we modify the exception message currently used or introduce a new exception type, etc., we must make sure that the exception message contains "Ensure that the compiler uses the '-parameters' flag".

Otherwise, we'll render Spring Boot's failure analysis useless, since it depends on the exception message containing exactly that sub-string.

https://github.com/spring-projects/spring-boot/blob/b5de38787c6abd4fc6522aa006b3d460ae23ffc5/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MissingParameterNamesFailureAnalyzer.java#L38

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: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants