Error in SonarLint for IntelliJ for a new file that has an empty space at the end of its name

Environment:

  • Java: JetBrains s.r.o. 11.0.14.1
  • OS: Windows 10 amd64
  • IDE: IntelliJ IDEA 2022.1
  • SonarLint: 6.7.0.45926
java.nio.file.InvalidPathException: Trailing char < > at index 46: terraform/modules/sns/modules-sns-variables.tf 
	at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:191)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
	at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
	at java.base/java.nio.file.Path.of(Path.java:147)
	at java.base/java.nio.file.Paths.get(Paths.java:69)
	at o.ss.sl.core.client.api.common.FileExclusions.test(FileExclusions.java:83)
	at o.sl.ij.analysis.LocalFileExclusions.checkExclusionsFromSonarLintSettings(LocalFileExclusions.java:117)
	at o.sl.ij.analysis.LocalFileExclusions.lambda$onTheFlyExclusionCheckers$4(LocalFileExclusions.java:198)
	at o.sl.ij.analysis.LocalFileExclusions.checkExclusionsFileByFile(LocalFileExclusions.java:183)
	at o.sl.ij.analysis.LocalFileExclusions.retainNonExcludedFilesByModules(LocalFileExclusions.java:158)
	at o.sl.ij.ui.AutoTriggerStatusPanel.lambda$switchCards$2(AutoTriggerStatusPanel.java:87)
	at c.ij.oa.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:295)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

Hi @andrei-ivanov

This seems to be a limitation of integration between JDK and Windows filesystem. See this bug report for more details: https://bugs.openjdk.java.net/browse/JDK-8156657

They seem to say it is normally not valid on Windows to have trailing spaces in filenames. How do you end up in this situation? Are you using a specific filesystem (network attached storage maybe?)

Hmm, there was something strange here… I copied the file name and that white space ended up in the end of it and then right clicked on the folder, chose new file and pasted the name and after I clicked enter I saw that error.
But, AFAIS, the actual created file does not have that empty space at the end, so maybe IDEA did some processing after…

Thanks for the details. I don’t have access to a Windows machine now, but I created a ticket that we will investigate in our next sprint:
https://jira.sonarsource.com/browse/SLI-715