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

Unused SLF4j Logger created with lomboks @Slf4j annotation creates exception #2227

Closed
timmhirsens opened this issue Mar 8, 2021 · 1 comment

Comments

@timmhirsens
Copy link

timmhirsens commented Mar 8, 2021

Description of the problem

Unused SLF4j Logger created with lomboks @Slf4j annotation creates exception during error_prone static analysis:

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Given the following class

import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TestClass {
	public void test() {
		System.out.println("Hello");
	}
}

Running mvn compile with the following configuration in pom.xml

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<target>${java.version}</target>
					<source>${java.version}</source>
					<compilerArgs>
						<arg>-XDcompilePolicy=simple</arg>
						<arg>-Xplugin:ErrorProne</arg>
					</compilerArgs>
					<annotationProcessorPaths>
						<path>
							<groupId>org.mapstruct</groupId>
							<artifactId>mapstruct-processor</artifactId>
							<version>${org.mapstruct.version}</version>
						</path>
						<path>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
							<version>1.18.18</version>
						</path>
						<dependency>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok-mapstruct-binding</artifactId>
							<version>0.2.0</version>
						</dependency>
						<path>
							<groupId>org.springframework</groupId>
							<artifactId>spring-context-indexer</artifactId>
							<version>5.3.4</version>
						</path>
						<path>
							<groupId>org.springframework.boot</groupId>
							<artifactId>spring-boot-configuration-processor</artifactId>
							<version>${spring.boot.version}</version>
						</path>
						<path>
							<groupId>com.google.errorprone</groupId>
							<artifactId>error_prone_core</artifactId>
							<version>2.5.1</version>
						</path>
					</annotationProcessorPaths>
					<forceJavacCompilerUse>true</forceJavacCompilerUse>
				</configuration>

Creates the following error:

[ERROR] TestClass.java:[1] error: An unhandled exception was thrown by the Error Prone static analysis plugin.
[ERROR]      Please report this at https://github.com/google/error-prone/issues/new and include the following:
[ERROR]   
[ERROR]      error-prone version: 2.5.1
[ERROR]      BugPattern: UnusedVariable
[ERROR]      Stack Trace:
[ERROR]      java.lang.IndexOutOfBoundsException
[ERROR] -> [Help 1]

What version of Error Prone are you using?

2.5.1

Have you found anything relevant by searching the web?

There seems to be earlier issues with lombok & error-prone

@cushon
Copy link
Collaborator

cushon commented Mar 8, 2021

#1250

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

No branches or pull requests

2 participants