Return of instance of anonymous, local or inner class
Reports return
statements that return an instance of an anonymous, local, or inner class. Such instances keep an implicit reference to the outer instance, which can prevent the outer instance from being garbage-collected. Any caller of a method returning such an instance might cause a memory leak by holding on to the instance returned.
Configure the inspection:
Use the Ignore returns from non-public methods option to ignore returns from
protected
or package-private methods. Returns fromprivate
methods are always ignored.
Inspection options
Option | Type | Default |
---|---|---|
Ignore returns from non-public methods | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023