Bug - SVN SCM PlugIn - svnkit.doStatus(....) might return null.

162 views
Skip to first unread message

andreas...@googlemail.com

unread,
Jul 14, 2015, 3:10:25 AM7/14/15
to sona...@googlegroups.com
Hello,

I fear that my code base exposed a bug in the SVN SCM plugin. svnkit.doStatus(...) seems to return null in some cases, which leads to the following exception.

Caused by: java.lang.NullPointerException
    at org.sonar.plugins.scm.svn.SvnBlameCommand.blame(SvnBlameCommand.java:73)
    at org.sonar.plugins.scm.svn.SvnBlameCommand.blame(SvnBlameCommand.java:52)
    at org.sonar.batch.scm.ScmSensor.execute(ScmSensor.java:84)
    at org.sonar.batch.scan.SensorWrapper.analyse(SensorWrapper.java:59)
    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:59)
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:51)
    at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:120)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)

Please let me know if you need more information.

Br,

Andreas

Julien HENRY

unread,
Jul 15, 2015, 4:20:24 AM7/15/15
to sona...@googlegroups.com, andreas...@googlemail.com, andreas...@googlemail.com
Hi Andreas,

I don't find any information in SVNKit about why the status command may return null. I think the full stack trace should display the name of the offending file. Is there anything special about it? I would like to be able to reproduce to better investigate.

Thanks

Julien

Björn Kautler

unread,
Jul 15, 2015, 5:01:28 AM7/15/15
to Julien HENRY, sona...@googlegroups.com, andreas...@googlemail.com
Hi Julien,

the doStatus() returns null if you feed it a File object of a
non-existing file or folder.
If the file or folder exists on disk, it should return an object, no
matter whether it is under version control or not.

Regards
Björn
> --
> You received this message because you are subscribed to the Google Groups
> "SonarQube" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sonarqube+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sonarqube/b4833a6c-ce12-48ec-99e1-06a683bddece%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Julien HENRY

unread,
Jul 15, 2015, 5:14:15 AM7/15/15
to Björn Kautler, sona...@googlegroups.com, andreas...@googlemail.com
> the doStatus() returns null if you feed it a File object of a non-existing file or folder

How do you manage to make SQ ask for blame of a non existing file?

andreas...@googlemail.com

unread,
Jul 15, 2015, 5:44:09 AM7/15/15
to sona...@googlegroups.com, Bjo...@kautler.net, andreas...@googlemail.com
Hi Julien, Hi Björn,

I've added the following code to the plugin to avoid the NPE:
if (status == null) {
LOG.debug("File " + inputFile + " returns no svn state. Skipping it.");
return;
}

Now the plugin produces the following output:
File [moduleKey=soloplan:Soloplan.CarLo.Business, relative=IKnowledgeEntryOp.cs, basedir=C:\project.net.sonar.playground\Soloplan\CarLo\Business] returns no svn state. Skipping it.

After taking a closer look at the file I'm now noticing a subtle difference - the file name casing.
On disk it is "IKnowledgeEntryOP.cs", but in the csproj-File includes - <Compile Include="IKnowledgeEntryOp.cs" />

So at least this should be easy to reproduce ;-)

Best regards,

Andreas

Julien HENRY

unread,
Jul 15, 2015, 9:52:14 AM7/15/15
to sona...@googlegroups.com, andreas...@googlemail.com, andreas...@googlemail.com, Bjo...@kautler.net
Cool, thanks for the investigation. Ticket created:

Not very high priority according to me, you can easily fix your csproj file.

++

Julien

andreas...@googlemail.com

unread,
Jul 15, 2015, 10:00:25 AM7/15/15
to sona...@googlegroups.com, Bjo...@kautler.net, andreas...@googlemail.com
Hi Julien,
thanks, I agree that this isn't a high priority issue. Nonetheless I believe that this should be fixed in someway - maybe by just ignoring it with some logging as I did.
You just need to consider that some user might work in a large environment - thousands of source files and dozens of developers - and so you couldn't expect that everything is 100% accurate. Inconsistencies are the rule not the exception!
In our code base I received 33 "returns no svn state" warnings ;-( Also take into account that this issue occurred after migration from sonarqube v4.1.2 to v5.1.1 - so this inconsistency wasn't problematic for the old plugins.
Best regards,
Andreas

Julien HENRY

unread,
Jul 15, 2015, 10:21:13 AM7/15/15
to sona...@googlegroups.com, andreas...@googlemail.com, Bjo...@kautler.net, andreas...@googlemail.com
I agree this should be fixed, but I disagree on the solution: ignoring files silently will only lead to have user later wondering why they don't have blame information on those files.

++

Andreas

unread,
Aug 11, 2015, 1:59:21 AM8/11/15
to SonarQube, andreas...@googlemail.com, Bjo...@kautler.net
Hi Julien,

could you please add the logging at least of the filename for this case. I've switched to your hotfix release for http://jira.sonarsource.com/browse/SONARSCSVN-6 and so I've lost my adaption of the plugin containing the logging. For sure I can readd it, but all your other users are still facing a pretty useless error message. Thanks in advance.

Best regards,

Andreas

ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:100)
    at org.sonar.runner.Main.executeTask(Main.java:70)
    at org.sonar.runner.Main.execute(Main.java:59)
    at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.NullPointerException
    at org.sonar.plugins.scm.svn.SvnBlameCommand.blame(SvnBlameCommand.java:80)
    at org.sonar.plugins.scm.svn.SvnBlameCommand.blame(SvnBlameCommand.java:59)
    ... 9 more

jul...@duvanel.ch

unread,
Aug 12, 2015, 10:39:29 AM8/12/15
to SonarQube, andreas...@googlemail.com, Bjo...@kautler.net
Hello,

Thank you for all your messages. I have exactly the same problem as Andreas mentionned. I would like to correct my .csproj file and I would love to have the logging of the filename.

Thank you very much in advance,

Best regards,

J.

Julien Duvanel

unread,
Aug 13, 2015, 3:55:56 AM8/13/15
to SonarQube
Hello again,

I would like to give you a little bit more informations. The problem was exactly the same in my case (letter case was different). However, it was not in my *.csproj.

My colleague developped a file and committed it to the svn without adding the file to the .csproj. It was something he had to do. The problem was:
  • Xxx.ascx;
  • xxx.ascx.cs;
  • Xxx.ascx.designer.cs.
The plugin crashed on xxx.ascx.cs (it was looking for Xxx.ascx.cs instead) and therefore crashed the whole sonar analysis.

Have a nice day,

Julien


--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/Hk7q1doCqwk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/a999dd36-1478-4eee-b9cc-4badac0e22d7%40googlegroups.com.

Julien HENRY

unread,
Aug 25, 2015, 3:58:53 AM8/25/15
to SonarQube, jul...@duvanel.ch
Hi guys,

I have created https://jira.sonarsource.com/browse/SONARSCSVN-7 and I will start a vote soon.

++
To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages