Multi-threaded API

Is it safe to have multiple threads use the SensorContext#newIssue() and NewIssue#save() methods ? In the context of batch Sonar Scanner, not in SonarLint.
Context: working on a language plugin where the usual codebase has 2k files, but can easily go up to 30k files. The longest phase is the sensor which execute the parser on each file, generate the AST and then execute the lint rules. Files are analyzed sequentially ; the ability to start multiple threads would really speed up the analysis (if the machine has enough CPU). Is it safe to report issues from multiple threads ?

Gilles

Hi @gquerret

No it is not.

You can write a multi-threaded sensor, but you need a synchronization to prevent concurrent calls to SensorContext or any other API.

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