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

Minor: warning in Spring Tools with Lombok on ConfigurationProperties #17650

Closed
cyril-gambis opened this issue Jul 26, 2019 · 4 comments
Closed
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid

Comments

@cyril-gambis
Copy link

cyril-gambis commented Jul 26, 2019

Hi,

I am using Lombok 1.18.8 with Spring Tool Suite 4 (Full Eclipse environment) version 4.3.1 RELEASE.

I have the following class:

@Data
@ConfigurationProperties("myprops")
@Configuration
public class ApplicationProperties {

    private Auth auth;    
    @Data
    public static class Auth {
    	@NotBlank
        private String resourceId;
    	@NotBlank
        private String kfName;
    	@NotBlank
        private String ksPass;
(...)

Previously, with Spring Tool Suite 4.0.2, it worked fine without any issue. But with the version 4.3.1 of STS, I get a strange warning on the definition of class "Auth": "Failed to generated type descriptor for com....ApplicationProperties.Auth".

Since its just a warning, I can just ignore it; but maybe there are some impacts I am not aware of?

I found that the code that generate this warning is here: https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java

Thanks,
Cyril

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 26, 2019
@snicoll
Copy link
Member

snicoll commented Jul 26, 2019

Thanks for the report but I don't understand how Spring Tool Suite is related to the problem you are reporting. My best guess is that the Eclipse compiler has yet another subtle difference with the regular compiler that Maven uses (i.e. guessing you don't get this warning when building the project on the command line but it would be nice if you could clarify that).

We need more information to assess the problem. The full stacktrace for a start, a small project we can import in STS ourselves that reproduces the problem would be ideal.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Jul 26, 2019
@cyril-gambis
Copy link
Author

Hi,

Thanks for your feedback.

I thought it was related to STS, because the code that generates the warning message is in STS codebase, but indeed, it might come from Eclipse 😕

I have created a project that reproduces the issue: https://github.com/cyril-gambis/demo-bug

When I open the "ApplicationProperties" class, and change something and save, I have a warning that appears in Eclipse:
image

Thanks,
Cyril

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 29, 2019
@wilkinsona
Copy link
Member

Thanks for the sample, @cyril-gambis. I've managed to reproduce the problem, but have only been able to do so when running Eclipse on JDK 11. Thus far, it does not appear to occur when using JDK 8.

Unfortunately, TypeUtils swallows the exception that's thrown so it's not obvious what the cause of the failure is. We have some room for improvement there. Debugging the Eclipse process makes the stack trace accessible. It is:

org.eclipse.jdt.internal.compiler.problem.AbortCompilation: 
	at org.eclipse.jdt.internal.core.builder.NameEnvironment.findClass(NameEnvironment.java:476)
	at org.eclipse.jdt.internal.core.builder.NameEnvironment.findType(NameEnvironment.java:546)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.lambda$0(LookupEnvironment.java:235)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForTypeFromModules(LookupEnvironment.java:371)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:234)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getType(LookupEnvironment.java:1691)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getType(LookupEnvironment.java:1660)
	at org.eclipse.jdt.internal.compiler.apt.model.ElementsImpl9.getTypeElement(ElementsImpl9.java:81)
	at org.eclipse.jdt.internal.compiler.apt.model.ElementsImpl9.getTypeElement(ElementsImpl9.java:53)
	at org.springframework.boot.configurationprocessor.TypeUtils.process(TypeUtils.java:186)
	at org.springframework.boot.configurationprocessor.TypeUtils.createTypeDescriptor(TypeUtils.java:176)
	at org.springframework.boot.configurationprocessor.TypeUtils.getType(TypeUtils.java:131)
	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.lambda$processSimpleTypes$0(ConfigurationMetadataAnnotationProcessor.java:276)
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
	at java.base/java.util.Collections$UnmodifiableMap.forEach(Collections.java:1503)
	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.processSimpleTypes(ConfigurationMetadataAnnotationProcessor.java:267)
	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.processTypeElement(ConfigurationMetadataAnnotationProcessor.java:259)
	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.processNestedType(ConfigurationMetadataAnnotationProcessor.java:389)
	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.lambda$processNestedTypes$2(ConfigurationMetadataAnnotationProcessor.java:329)
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
	at java.base/java.util.Collections$UnmodifiableMap.forEach(Collections.java:1503)
	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.processNestedTypes(ConfigurationMetadataAnnotationProcessor.java:327)
	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.processTypeElement(ConfigurationMetadataAnnotationProcessor.java:261)
	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.processAnnotatedTypeElement(ConfigurationMetadataAnnotationProcessor.java:235)
	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.processElement(ConfigurationMetadataAnnotationProcessor.java:220)
	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.process(ConfigurationMetadataAnnotationProcessor.java:162)
	at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:142)
	at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:124)
	at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:171)
	at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:138)
	at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:940)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:450)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:386)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:371)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:318)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.incrementalBuildLoop(IncrementalImageBuilder.java:186)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:143)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:279)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:200)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:833)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:220)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:263)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:316)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:319)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:371)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:392)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

This is the result of calling getTypeElement("com.example.demo.ApplicationProperties.Auth").

@wilkinsona
Copy link
Member

wilkinsona commented Aug 27, 2019

I've opened #17974 to improve the diagnostics.

The relevant code in NameEnviroment is the following:

	String moduleQualifiedName = moduleName != null ? moduleName+':'+qualifiedTypeName : qualifiedTypeName;
	if (this.initialTypeNames != null && this.initialTypeNames.includes(moduleQualifiedName)) {
		if (this.isIncrementalBuild)
			// catch the case that a type inside a source file has been renamed but other class files are looking for it
			throw new AbortCompilation(true, new AbortIncrementalBuildException(qualifiedTypeName));
		return null; // looking for a file which we know was provided at the beginning of the compilation
	}

The mention of modules ties in with the problem not occurring on JDK 8 where this is no module system.

As far as I can tell Boot's annotation processor isn't doing anything wrong here. When I was modifying Auth to trigger compilation I was not changing its name so, judging by the comment in the JDT source code, it appears that the exception should not be thrown.

@cyril-gambis Unfortunately, I don't think there's anything we can do to fix this in Spring Boot. Can you please open an Eclipse bug and comment here with a link to it so that we can follow along and comment as needed.

Note that this may be a Lombok bug as I could not reproduce the problem on any JDK without Lombok. For the problem to occur at least ApplicationProperties must be annotated with @Data. The Auth inner-class does not have to be annotated with @Data for the problem to occur. I think the Eclipse JDT team are best-placed to determine if it's a JDT issue or a Lombok issue.

@wilkinsona wilkinsona added for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants