org.eclipse.jface.text.BadLocationException in Sonar in combination with Save actions for the formatter and undo

I’m getting on a regular basis the following exception.

How to reproduce:
1.) Enable save action especially the Formatter
2.) Write a long line of code, longer than the formatter will allow
3.) Save -> Formatter will break the line into tow
4.) Press Ctrl+Z to undo the formatter action

-> Exception

failed to get text range content of resource /org.eclipse.core.resources/src/org/eclipse/core/internal/resources/
	at org.eclipse.jface.text.AbstractDocument.get(
	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.get(
	at java.base/$3$1.accept(
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(
	at java.base/
	at java.base/
	at java.base/$ReduceOp.evaluateSequential(
	at java.base/
	at java.base/

Hi Lars,

Thanks for reporting this. I spent some time on it but I was not able to reproduce. There is probably something more in the loop. Can you just precise:

  • the version of SonarLint you are using (I’m assuming
  • are you using connected mode to bind your project to a specific SonarQube server or SonarCloud?
  • is the analysis of the file slow (it may increase the likelihood of a race condition)?

It might be interesting to share the SonarLint verbose console output if you can reproduce consistently the issue.


Hi Julian,

1.) SonarSource SonarLint for Eclipse org.sonarlint.eclipse.feature
2.) No
3.) The workspace is big so everything is slow.

As for the verbose output: Do you have a trace available? Or where do I see the output?

Please open the SonarLint console (in the console view), and use the toolbar to enable verbose and analysis logs:
Clear the console, reproduce the bug, then please collect all logs.

Also, do you have any issue reported on the line you are editing (prior editing?)

I now see that the file is excluded:

File ‘src/org/eclipse/core/internal/resources/’ excluded by ‘JavaProjectConfiguratorExtension’

Why is that?

If you are in the middle of an edition when you save, the code may be unparseable/have compilation errors, so we are trying to save time by skipping analysis (our analyzers only accept well-formed code).

If the analysis is skipped, it should not lead to the error you mentioned earlier. Are you talking about the same file/problem?

IIRC this was the file for which Sonar gave the exeception. Currently I’m unable to reproduce but once I see the error again I post the log.

Closing this thread due to lack of activity.

Feel free to open a new thread if you still have an issue/question.