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

Unnecessary parameter name introspection for constructor-arg resolution (leading to LocalVariableTableParameterNameDiscoverer warnings) #29912

Closed
jloisel opened this issue Jan 31, 2023 · 2 comments
Labels
for: stackoverflow A question that's better suited to stackoverflow.com in: web Issues in web modules (web, webmvc, webflux, websocket) status: invalid An issue that we don't feel is valid

Comments

@jloisel
Copy link

jloisel commented Jan 31, 2023

[http-nio-8090-exec-7] WARN org.springframework.core.LocalVariableTableParameterNameDiscoverer - Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: com.octoperf.analysis.rest.server.controller.BenchReportsController
[http-nio-8090-exec-1] WARN org.springframework.core.LocalVariableTableParameterNameDiscoverer - Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: com.octoperf.design.rest.spring.ProjectFilesController
[http-nio-8090-exec-2] WARN org.springframework.core.LocalVariableTableParameterNameDiscoverer - Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: com.octoperf.analysis.rest.server.controller.GraphsController
[http-nio-8090-exec-4] WARN org.springframework.core.LocalVariableTableParameterNameDiscoverer - Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: com.octoperf.analysis.rest.server.controller.MetricsController

Using Spring Boot 3.0.2 with Spring 6.0.4.

Example Controller:

@RestController
@RequestMapping("/analysis/bench-reports")
@AllArgsConstructor(access = PACKAGE)
@FieldDefaults(level = PRIVATE, makeFinal = true)
class BenchReportsController extends AbstractUserCrudController<BenchReport> {
  @NonNull
  BenchReportCrudService benchReports;
....
}

We don't use any parameter name in autowired constructors.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 31, 2023
@bclozel
Copy link
Member

bclozel commented Jan 31, 2023

This is a deliberate behavior change introduced in #29531. This fallback will be removed in the future so a configuration change is required in your projects.

This warning is not about constructor injection, but in this case the fact that Spring MVC will look at controller method parameters for injection (for example, @RequestParam arguments). I would suggest following the advice here and enable the "-parameters" compilation flag in your build file as it's easy to apply and doesn't require any code change.

Thanks!

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2023
@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) status: invalid An issue that we don't feel is valid for: stackoverflow A question that's better suited to stackoverflow.com and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 31, 2023
@jloisel
Copy link
Author

jloisel commented Jan 31, 2023

The problem is, we use code obfuscation in later stage which removes the parameter names from the byte-code. It's not as simple as it seems, but thanks anyway.

Since we cannot use "-parameters" in compiler args, what are our other options to avoid this issue? We always annotate controller method parameters with @RequestParam, @PathVariable or @p.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: stackoverflow A question that's better suited to stackoverflow.com in: web Issues in web modules (web, webmvc, webflux, websocket) status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants