Make sure to read this post before raising a thread here:
Then tell us:
- What language is this for? Java
- Which rule?
java:S6857
“SpEL expression should have a valid syntax”
- Why do you believe it’s a false-positive/false-negative?
Syntax working fine for injecting directly into a Map as presented here: https://www.baeldung.com/spring-value-annotation#using-value-with-maps
- Using SonarCloud
- How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
public class TestConfiguration {
@Value("#{${valuesMap}}")
private Map<String, Integer> valuesMap;
}
Hello @theBlackDragon,
Thanks for the report. I was able to reproduce the issue, Here is the ticket to fix it: [SONARJAVA-4917] - Jira
Best,
Margarita
1 Like
Hi , we also noticed it happens when the default value is empty it complains of malformed property.
Eg.:
@Value("${management.metrics.server.excluded-uris:}")
private List<String> excludedUris;
Where the default would be an empty array by applying the :
1 Like
Thanks @LucasDesenv,
I added another example to the ticket.
Best,
Margarita
asoldo11
(Antonio Soldo)
15
Hi Margarita,
Is there any information about the ticket? Will it be fixed, and if so, when?
ganncamp
(G Ann Campbell)
16
Hi @asoldo11,
You can check the ticket in Jira to see its status.
HTH,
Ann
Hi,
This also seems to happen when the default value is a list
@Value("${application.animals:cat,dog}")
private List<String> animals;
1 Like
Hey @Ville_Mustonen,
Welcome to the community, and thank you for reporting this issue!
I have been unable to reproduce the false-positive with the example you shared.
Could you create a new thread and share a bit more details about which versions of Spring and the products you are using?
This would help us greatly triage and narrow down where the problem is coming from.
Cheers,
Dorian