java:S6804 false positive for @Value on Resource

Rule java:S6804: "@Value" annotation should inject property or SpEL expression gives a false positive for @Value on Resource. This rule was added with [SONARJAVA-4643] - Jira in Sonar Java version

This code is valid and should not produce a warning, but Sonar incorrectly flags it:

public class TestComponent {
	private Resource someXml;


1 Like

Hi @candrews ,

This is indeed an FP. Thank you for reporting it and providing a link to the documentation. We missed it when we worked on the rule.

I have created a ticket about the issue and you can track its progress here. For now, you can mark the issue as an FP.