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

Parameter names are not retained for endpoints in EnvironmentController #2657

Closed
cloudbackenddev opened this issue Nov 28, 2024 · 1 comment

Comments

@cloudbackenddev
Copy link

Describe the bug
We are using spring-cloud-config-server (4.1.1) to load environment configuration from s3 repository. We are getting intermittent failure with 403 error during a refresh call (http://:port/service-name/profile). The exception getting logged is as follows

exception.message:
"Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag."
exception.stacktrace:
"java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.
at org.springframework.web.method.annotati…ctor.lambda$createCacheFilter$3(HandlerMappingIntrospector.java:195)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:113)
at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:"
exception.type:
"java.lang.IllegalArgumentException"

The error occurs due to invocation of following method (EnvironmentController.defaultLabelIncludeOrigin)).
It seems the parameter names are not retained which causes the above failure. As per spring 6.1 release notes it has been mentioned to pass following parameter in maven compiler plugin "true". We are adding spring cloud config server jar as dependency. Is the spring cloud config server jar compiled in such a way to retain parameter names. I see the error is not consistent. It occurs intermittently

@GetMapping(path = "/{name}/{profiles:(?!.\b\.(?:ya?ml|properties|json)\b).}",
produces = EnvironmentMediaType.V2_JSON)
public Environment defaultLabelIncludeOrigin(@PathVariable String name, @PathVariable String profiles) {
return getEnvironment(name, profiles, null, true);
}

Spring 6.1 release notes reference

https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-6.1-Release-Notes

LocalVariableTableParameterNameDiscoverer has been removed in 6.1. Consequently, code within the Spring Framework and Spring portfolio frameworks no longer attempts to deduce parameter names by parsing bytecode. If you experience issues with dependency injection, property binding, SpEL expressions, or other use cases that depend on the names of parameters, you should compile your Java sources with the common Java 8+ -parameters flag for parameter name retention (instead of relying on the -debug compiler flag) in order to be compatible with StandardReflectionParameterNameDiscoverer

@cloudbackenddev
Copy link
Author

Able to resolve by having a CustomEnvironmentController with same path mapping but different root context which delegates to EnvironmentController.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant