FP after ignoring org.springframework.util.StringUtils parameter validation

Last line of the snippet is reported as an issue:
A “NullPointerException” could be thrown; “fileName” is nullable here.

However before fileName is used, check is made using StringUtils library and if fileName is indeed equal to null, exception is thrown.

  • versions used (SonarQube, Revision: a27f41e4ae5e8a41ab9b19f8dd6d86d7b384dad4)
  • minimal code sample to reproduce:
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
public void readFile(MultipartFile file) {
        String fileName = file.getOriginalFilename();
        if (StringUtils.isEmpty(fileName)) {
            throw new Exception();
        String ext = fileName.substring(fileName.lastIndexOf('.'));

Hi Aleksandar,
The java analyzer supports some isEmpty methods, but not this one.
So I created the ticket SONARJAVA-4131 to support it.
Thanks for your contribution.

Hi Alban,

I’m glad I could help and thank you for striving to make this great tool even better.


1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.