Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE if you open a file that is not analyzed by sonar #17

Closed
Vampire opened this issue Feb 18, 2013 · 5 comments
Closed

NPE if you open a file that is not analyzed by sonar #17

Vampire opened this issue Feb 18, 2013 · 5 comments

Comments

@Vampire
Copy link

Vampire commented Feb 18, 2013

null
java.lang.NullPointerException
    at org.sonar.ide.intellij.utils.SonarCache.getSource(SonarCache.java:42)
    at org.sonar.ide.intellij.inspection.SonarViolationInspection$2.compute(SonarViolationInspection.java:53)
    at org.sonar.ide.intellij.inspection.SonarViolationInspection$2.compute(SonarViolationInspection.java:50)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:892)
    at org.sonar.ide.intellij.inspection.SonarViolationInspection.checkFile(SonarViolationInspection.java:50)
    at com.intellij.codeInspection.LocalInspectionTool$1.visitFile(LocalInspectionTool.java:129)
    at com.intellij.extapi.psi.PsiFileBase.accept(PsiFileBase.java:70)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.a(LocalInspectionsPass.java:403)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.access$400(LocalInspectionsPass.java:76)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$3.process(LocalInspectionsPass.java:379)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$3.process(LocalInspectionsPass.java:373)
    at com.intellij.concurrency.JobUtil$2$1.run(JobUtil.java:117)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:218)
    at com.intellij.concurrency.JobUtil$2.process(JobUtil.java:115)
    at com.intellij.concurrency.JobUtil$1.run(JobUtil.java:57)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at com.intellij.concurrency.PrioritizedFutureTask.access$101(PrioritizedFutureTask.java:31)
    at com.intellij.concurrency.PrioritizedFutureTask$1.run(PrioritizedFutureTask.java:70)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1053)
    at com.intellij.concurrency.PrioritizedFutureTask.run(PrioritizedFutureTask.java:97)
    at com.intellij.concurrency.JobImpl.scheduleAndWaitForResults(JobImpl.java:136)
    at com.intellij.concurrency.JobUtil.a(JobUtil.java:71)
    at com.intellij.concurrency.JobUtil.invokeConcurrentlyUnderProgress(JobUtil.java:112)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.a(LocalInspectionsPass.java:389)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.a(LocalInspectionsPass.java:225)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.collectInformationWithProgress(LocalInspectionsPass.java:134)
    at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:58)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:61)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:350)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1053)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:342)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:218)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.a(PassExecutorService.java:340)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:316)
    at com.intellij.concurrency.JobUtil$3.call(JobUtil.java:134)
    at com.intellij.concurrency.JobUtil$3.call(JobUtil.java:131)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at com.intellij.concurrency.PrioritizedFutureTask.access$101(PrioritizedFutureTask.java:31)
    at com.intellij.concurrency.PrioritizedFutureTask$1.run(PrioritizedFutureTask.java:70)
    at com.intellij.concurrency.PrioritizedFutureTask.run(PrioritizedFutureTask.java:113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)



java.lang.NullPointerException
    at org.sonar.ide.intellij.utils.SonarCache.getSource(SonarCache.java:42)
    at org.sonar.ide.intellij.inspection.SonarViolationInspection$2.compute(SonarViolationInspection.java:53)
    at org.sonar.ide.intellij.inspection.SonarViolationInspection$2.compute(SonarViolationInspection.java:50)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:892)
    at org.sonar.ide.intellij.inspection.SonarViolationInspection.checkFile(SonarViolationInspection.java:50)
    at com.intellij.codeInspection.LocalInspectionTool$1.visitFile(LocalInspectionTool.java:129)
    at com.intellij.extapi.psi.PsiFileBase.accept(PsiFileBase.java:70)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.a(LocalInspectionsPass.java:403)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.access$400(LocalInspectionsPass.java:76)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$3.process(LocalInspectionsPass.java:379)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$3.process(LocalInspectionsPass.java:373)
    at com.intellij.concurrency.JobUtil$2$1.run(JobUtil.java:117)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:218)
    at com.intellij.concurrency.JobUtil$2.process(JobUtil.java:115)
    at com.intellij.concurrency.JobUtil$1.run(JobUtil.java:57)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at com.intellij.concurrency.PrioritizedFutureTask.access$101(PrioritizedFutureTask.java:31)
    at com.intellij.concurrency.PrioritizedFutureTask$1.run(PrioritizedFutureTask.java:70)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1053)
    at com.intellij.concurrency.PrioritizedFutureTask.run(PrioritizedFutureTask.java:97)
    at com.intellij.concurrency.JobImpl.scheduleAndWaitForResults(JobImpl.java:136)
    at com.intellij.concurrency.JobUtil.a(JobUtil.java:71)
    at com.intellij.concurrency.JobUtil.invokeConcurrentlyUnderProgress(JobUtil.java:112)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.a(LocalInspectionsPass.java:389)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.a(LocalInspectionsPass.java:225)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.collectInformationWithProgress(LocalInspectionsPass.java:134)
    at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:58)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:61)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:350)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1053)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:342)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:218)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.a(PassExecutorService.java:340)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:316)
    at com.intellij.concurrency.JobUtil$3.call(JobUtil.java:134)
    at com.intellij.concurrency.JobUtil$3.call(JobUtil.java:131)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at com.intellij.concurrency.PrioritizedFutureTask.access$101(PrioritizedFutureTask.java:31)
    at com.intellij.concurrency.PrioritizedFutureTask$1.run(PrioritizedFutureTask.java:70)
    at com.intellij.concurrency.PrioritizedFutureTask.run(PrioritizedFutureTask.java:113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
@aheusingfeld
Copy link
Collaborator

Same here

  • sonar-intellij-plugin-1.0.4
  • idea-12.1.0 (126.232)
  • JDK1.6.0_32
  • WinXP

@Vampire
Copy link
Author

Vampire commented Feb 18, 2013

idea 11 here, though I don't think it matters for this bug. :-)
I guess it is just about replacing if (sources.isEmpty()) { by if ((sources == null) || sources.isEmpty()) {

@gshakhn
Copy link
Owner

gshakhn commented Feb 18, 2013

Can't believe I didn't test this scenario. Wish it was easier to write unit tests for this type of stuff.

I'll fix this up tonight and make another release.

@gshakhn
Copy link
Owner

gshakhn commented Feb 19, 2013

This should be fixed in 1.0.5. Pre-built version has been updated on 11.x branch as well.

@gshakhn gshakhn closed this as completed Feb 19, 2013
@aheusingfeld
Copy link
Collaborator

Thanks for the quick response, George!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants