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

Compile sources with '-parameters' to retain method parameter names #3776

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented Apr 20, 2023

Fix warning raised by spring

o.s.c.LocalVariableTableParameterNameDiscoverer WARN Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: io.micrometer.core.aop.CountedAspect

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
@shakuzen
Copy link
Member

It'd be good to understand when/why this is happening. It may be that Spring should not even be doing introspection in this case. Compiling with -parameters masks the issue of unnecessary introspection. I see spring-projects/spring-framework#29612 and spring-projects/spring-framework#30103 were fixed as recently as 6.0.7. If you still get the issue on the latest framework version, can you get a stacktrace or share a minimal sample that reproduces the issue?

@shakuzen shakuzen added the waiting for feedback We need additional information before we can continue label Apr 20, 2023
@quaff
Copy link
Contributor Author

quaff commented Apr 20, 2023

@SpringBootTest
@ExtendWith(OutputCaptureExtension.class)
public class ApplicationTests {
    
    @Test
    void shouldNotOutputDeprecatedLogging(CapturedOutput output){
        assertThat(output).doesNotContain("Compile the affected code with '-parameters' instead or avoid its introspection: io.micrometer.core.aop.CountedAspect"); // failed
    }
}
plugins {
	id 'java'
	id 'org.springframework.boot' version '3.0.5'
	id 'io.spring.dependency-management' version '1.1.0'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
	mavenCentral()
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-aop'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	implementation 'org.springframework.boot:spring-boot-starter-actuator'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
	useJUnitPlatform()
}

countedaspect.zip

@quaff
Copy link
Contributor Author

quaff commented Apr 20, 2023

It's weird that TimedAspect is not affected, it's very similar with CountedAspect.

@shakuzen
Copy link
Member

Thank you for the quick response and the reproducer. I'm asking someone from the Spring Framework team to take a look to determine if there is something to fix on the framework side.

It's weird that TimedAspect is not affected, it's very similar with CountedAspect.

I agree, and I'm not sure why it's different.

@quaff
Copy link
Contributor Author

quaff commented Apr 20, 2023

It triggered by @Around("@annotation(counted)"), the name counted is binding to method parameter Counted counted, method parameter inspection is required,-debug is deprecated, we should switch to -parameter.

@Around("@annotation(counted)")
public Object interceptAndRecord(ProceedingJoinPoint pjp, Counted counted) throws Throwable {

@shakuzen
Copy link
Member

shakuzen commented Apr 20, 2023

Thank you for the analysis. I think we can change the aspect code so that referencing a named parameter is not necessary. I don't see any reason why we needed to do it that way.

Edit: I opened #3780 which should avoid the issue whether we compile with -parameters or not.

@shakuzen shakuzen added internal An issue that needs input from a member on another Team and removed waiting for feedback We need additional information before we can continue labels Apr 20, 2023
@shakuzen
Copy link
Member

@quaff with #3780 merged, could you try with the latest Micrometer snapshot 1.10.7-SNAPSHOT to see if that resolves the issue for you?

@jonatan-ivanov jonatan-ivanov added the superseded An issue that has been superseded by another label May 10, 2023
@jonatan-ivanov
Copy link
Member

Superseded by #3780

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An issue that needs input from a member on another Team superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants