NullPointerException while creating a new Java Project in IntelliJ IDEA

Template for a good bug report, formatted with Markdown:

  • Versions used (SonarLint 4.1.1.3345)
  • Error observed (wrap logs/code around triple quote ``` for proper formatting)

java.lang.NullPointerException
	at org.sonarsource.sonarlint.core.client.api.connected.objectstore.HashingPathMapper.toHash(HashingPathMapper.java:65)
	at org.sonarsource.sonarlint.core.client.api.connected.objectstore.HashingPathMapper.apply(HashingPathMapper.java:53)
	at org.sonarsource.sonarlint.core.client.api.connected.objectstore.HashingPathMapper.apply(HashingPathMapper.java:30)
	at org.sonarlint.intellij.issue.persistence.IndexedObjectStore.write(IndexedObjectStore.java:109)
	at org.sonarlint.intellij.issue.persistence.IssuePersistence.save(IssuePersistence.java:74)
	at org.sonarlint.intellij.issue.persistence.LiveIssueCache.lambda$flushAll$0(LiveIssueCache.java:105)
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
	at org.sonarlint.intellij.issue.persistence.LiveIssueCache.flushAll(LiveIssueCache.java:101)
	at org.sonarlint.intellij.issue.persistence.LiveIssueCache.projectClosed(LiveIssueCache.java:118)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.fireProjectClosed(ProjectManagerImpl.java:848)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.lambda$closeProject$16(ProjectManagerImpl.java:723)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:994)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.closeProject(ProjectManagerImpl.java:720)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.closeAndDispose(ProjectManagerImpl.java:744)
	at com.intellij.ide.impl.NewProjectUtil.closePreviousProject(NewProjectUtil.java:208)
	at com.intellij.ide.impl.NewProjectUtil.doCreate(NewProjectUtil.java:134)
	at com.intellij.ide.impl.NewProjectUtil.createFromWizard(NewProjectUtil.java:60)
	at com.intellij.ide.actions.ImportModuleAction.doCreateFromWizard(ImportModuleAction.java:112)
	at com.intellij.ide.actions.ImportModuleAction.lambda$createFromWizard$0(ImportModuleAction.java:95)
	at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:82)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:148)
	at com.intellij.ide.actions.ImportModuleAction.createFromWizard(ImportModuleAction.java:95)
	at com.intellij.ide.actions.ImportModuleAction.doImport(ImportModuleAction.java:89)
	at com.intellij.ide.actions.ImportProjectAction.actionPerformed(ImportProjectAction.java:30)
	at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:265)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:282)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:292)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:265)
	at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:107)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:282)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:111)
	at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:82)
	at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:106)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:115)
	at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:121)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:111)
	at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:524)
	at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:35)
	at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:546)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6651)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
	at java.desktop/java.awt.Component.processEvent(Component.java:6416)
	at java.desktop/java.awt.Container.processEvent(Container.java:2263)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5026)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4858)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2773)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4858)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:824)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:769)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:412)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:704)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:411)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)```
* Steps to reproduce
Create new project from existing sources
Select folder which contain two .java classes
* Potential workaround
Not found

I tried to reproduce but couldn’t. Is it possible to post the particular files that you used or an anonymized version of the files that still exhibit the error?

BTW, this might not be related to creating a new project. I see fireProjectClosed in the stack trace. Can you try closing the existing project that you had open and see if it re-produces the error?

Can’t reproduce it as well. Closing the existing project does not reproduce it. Even making another project from the same files doesn’t seem to reproduce it.
I uploaded those files I used in the first place (messed with extension to upload it here). Hope it’ll help.
IStringRowsListSorter.java.txt (2.3 KB)
Task1Impl.java.txt (1.1 KB)

Seems to have been an issue when storing issues on the disk cache. Without a reproducer, we could spend days on it, so I suggest to close this thread and reopen if this happen again.