dboissier / mongo4idea

MongoDB integration in Intellij
Apache License 2.0
975 stars 109 forks source link

java.lang.NullPointerException on Intellij IDEA 2018.2 start #224

Open sturman opened 6 years ago

sturman commented 6 years ago

Exception in Mongo Plugin happens on IDEA start

Environment:

Steps:

Actual result: NullPointerException happens on IDE start. Stacktrace:

org.codinjutsu.tools.mongo.view.model.MongoTreeBuilder

java.lang.NullPointerException
    at org.codinjutsu.tools.mongo.view.model.MongoTreeBuilder.lambda$new$43(MongoTreeBuilder.java:61)
    at com.intellij.ide.util.treeView.AbstractTreeUi$1.compare(AbstractTreeUi.java:75)
    at com.intellij.ide.util.treeView.AbstractTreeUi$1.compare(AbstractTreeUi.java:60)
    at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
    at java.util.TimSort.sort(TimSort.java:220)
    at java.util.Arrays.sort(Arrays.java:1512)
    at java.util.ArrayList.sort(ArrayList.java:1456)
    at java.util.Collections.sort(Collections.java:175)
    at com.intellij.ide.util.treeView.AbstractTreeBuilder.sortChildren(AbstractTreeBuilder.java:469)
    at com.intellij.ide.util.treeView.AbstractTreeUi.sortChildren(AbstractTreeUi.java:3629)
    at com.intellij.ide.util.treeView.AbstractTreeUi.insertNodesInto(AbstractTreeUi.java:3559)
    at com.intellij.ide.util.treeView.AbstractTreeUi.access$4100(AbstractTreeUi.java:51)
    at com.intellij.ide.util.treeView.AbstractTreeUi$29.lambda$perform$0(AbstractTreeUi.java:1386)
    at com.intellij.openapi.util.AsyncResult.lambda$doWhenDone$1(AsyncResult.java:46)
    at com.intellij.openapi.util.ExecutionCallback.doWhenExecuted(ExecutionCallback.java:100)
    at com.intellij.openapi.util.ActionCallback.doWhenDone(ActionCallback.java:111)
    at com.intellij.openapi.util.AsyncResult.doWhenDone(AsyncResult.java:46)
    at com.intellij.ide.util.treeView.AbstractTreeUi$29.perform(AbstractTreeUi.java:1385)
    at com.intellij.ide.util.treeView.TreeRunnable.run(TreeRunnable.java:23)
    at com.intellij.ide.util.treeView.TreeRunnable$TreeConsumer.accept(TreeRunnable.java:37)
    at org.jetbrains.concurrency.DonePromise.onSuccess(DonePromise.java:32)
    at com.intellij.ide.util.treeView.AbstractTreeUi.updateNodeChildrenNow(AbstractTreeUi.java:1365)
    at com.intellij.ide.util.treeView.AbstractTreeUi.access$3200(AbstractTreeUi.java:51)
    at com.intellij.ide.util.treeView.AbstractTreeUi$26.perform(AbstractTreeUi.java:1266)
    at com.intellij.ide.util.treeView.TreeRunnable.run(TreeRunnable.java:23)
    at com.intellij.ide.util.treeView.TreeRunnable$TreeConsumer.accept(TreeRunnable.java:37)
    at org.jetbrains.concurrency.AsyncPromise.callConsumerIfTargeted(AsyncPromise.kt:229)
    at org.jetbrains.concurrency.AsyncPromise.setHandler(AsyncPromise.kt:181)
    at org.jetbrains.concurrency.AsyncPromise.onSuccess(AsyncPromise.kt:26)
    at com.intellij.ide.util.treeView.AbstractTreeUi.doUpdateChildren(AbstractTreeUi.java:1262)
    at com.intellij.ide.util.treeView.AbstractTreeUi.access$3000(AbstractTreeUi.java:51)
    at com.intellij.ide.util.treeView.AbstractTreeUi$25$1.perform(AbstractTreeUi.java:1165)
    at com.intellij.ide.util.treeView.TreeRunnable.run(TreeRunnable.java:23)
    at com.intellij.ide.util.treeView.AbstractTreeUi.execute(AbstractTreeUi.java:1848)
    at com.intellij.ide.util.treeView.AbstractTreeUi.access$2600(AbstractTreeUi.java:51)
    at com.intellij.ide.util.treeView.AbstractTreeUi$25.perform(AbstractTreeUi.java:1162)
    at com.intellij.ide.util.treeView.TreeRunnable.run(TreeRunnable.java:23)
    at com.intellij.openapi.util.ActionCallback$ExecutedExecutionCallback.doWhenExecuted(ActionCallback.java:177)
    at com.intellij.openapi.util.ActionCallback.doWhenDone(ActionCallback.java:111)
    at com.intellij.ide.util.treeView.AbstractTreeUi.updateNodeChildren(AbstractTreeUi.java:1157)
    at com.intellij.ide.util.treeView.AbstractTreeUi.updateSubtreeNow(AbstractTreeUi.java:1061)
    at com.intellij.ide.util.treeView.AbstractTreeUpdater$3.perform(AbstractTreeUpdater.java:262)
    at com.intellij.ide.util.treeView.TreeRunnable.run(TreeRunnable.java:23)
    at com.intellij.openapi.util.ActionCallback$ExecutedExecutionCallback.doWhenExecuted(ActionCallback.java:177)
    at com.intellij.openapi.util.ActionCallback.doWhenDone(ActionCallback.java:111)
    at com.intellij.ide.util.treeView.AbstractTreeUpdater.performUpdate(AbstractTreeUpdater.java:257)
    at com.intellij.ide.util.treeView.AbstractTreeUpdater$2.run(AbstractTreeUpdater.java:218)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:337)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:327)
    at com.intellij.util.ui.update.MergingUpdateQueue.lambda$flush$1(MergingUpdateQueue.java:277)
    at com.intellij.util.ui.UIUtil.invokeAndWaitIfNeeded(UIUtil.java:3099)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:288)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:246)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:232)
    at com.intellij.util.Alarm$Request.runSafely(Alarm.java:405)
    at com.intellij.util.Alarm$Request.access$700(Alarm.java:330)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:371)
    at com.intellij.util.Alarm$Request.run(Alarm.java:382)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:228)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
    at java.awt.EventQueue.access$500(EventQueue.java:98)
    at java.awt.EventQueue$3.run(EventQueue.java:715)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:781)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:722)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382)
    at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:864)
    at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:205)
    at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:191)
    at com.intellij.openapi.application.impl.ApplicationImpl.runProcessWithProgressSynchronously(ApplicationImpl.java:584)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:446)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:109)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:250)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:203)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.loadProjectUnderProgress(ProjectManagerImpl.java:439)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.openProject(ProjectManagerImpl.java:414)
    at com.intellij.platform.PlatformProjectOpenProcessor.doOpenProject(PlatformProjectOpenProcessor.java:245)
    at com.intellij.ide.RecentProjectsManagerBase.doOpenProject(RecentProjectsManagerBase.java:579)
    at com.intellij.ide.RecentProjectsManagerBase.doReopenLastProject(RecentProjectsManagerBase.java:706)
    at com.intellij.ide.RecentProjectsManagerBase$MyAppLifecycleListener.appStarting(RecentProjectsManagerBase.java:748)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:117)
    at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:426)
    at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:387)
    at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:376)
    at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:357)
    at com.intellij.util.messages.impl.MessageBusImpl.access$200(MessageBusImpl.java:43)
    at com.intellij.util.messages.impl.MessageBusImpl$2.invoke(MessageBusImpl.java:208)
    at com.sun.proxy.$Proxy50.appStarting(Unknown Source)
    at com.intellij.idea.IdeaApplication$IdeStarter.lambda$main$1(IdeaApplication.java:371)
    at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
    at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:111)
    at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:120)
    at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)
    at com.intellij.idea.IdeaApplication$IdeStarter.main(IdeaApplication.java:369)
    at com.intellij.idea.IdeaApplication.lambda$run$1(IdeaApplication.java:209)
    at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:195)
    at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:209)
    at com.intellij.idea.IdeaApplication.lambda$initApplication$0(IdeaApplication.java:72)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
    at java.awt.EventQueue.access$500(EventQueue.java:98)
    at java.awt.EventQueue$3.run(EventQueue.java:715)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:361)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Expected: Plugin start without fatal error and without any exceptions

dboissier commented 6 years ago

Hi,

Thanks for reporting this bug. Will check it and provide a patch ASAP.

Regards

eddturtle commented 6 years ago

Just to chime in, I'm getting the exact same issue (the exception thrown above).

PhpStorm 2018.1.6 Build #PS-181.5281.35, built on June 14, 2018 JRE: 1.8.0_152-release-1136-b39 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 4.15.0-29-generic

dboissier commented 6 years ago

hi all,

what is your current configuration? 0 server, 1 or more than 1?

eddturtle commented 6 years ago

I had 2 servers before upgrading the plugin, now when I open it I see none. The add new server dialog loads but doesn't save the details so remains empty. (Hope this helps)

dboissier commented 6 years ago

I made a quick patch (Jetbrains may have changed the way to load the tree to make it more asynchronous). Please try this SNAPSHOT version and tell me whether it works on you IDE

eddturtle commented 6 years ago

Unfortunately that hasn't fixed it for me.

I downloaded the zip, installed it manually in plugins (which updated it), restarted phpstorm, same error. I tried to add a server didn't save. I removed the plugin completely, and added 0.12.1 and it came up with the same error.

Just realised I might not have been said earlier, I updated the mongo plugin, but I'm still on phpstorm 2018.1

https://www.dropbox.com/s/nc34t3i7u41dyl3/mongo-result1.png?dl=0 https://www.dropbox.com/s/1atuvkzridg3kfb/mongo-result2.png?dl=0

dboissier commented 6 years ago

Did you set a label for each configuration you set? If not, it might be the cause of the bug.

dboissier commented 6 years ago

I pushed a new snapshot (same link than above). Now the Label of the configuration is mandatory to prevent this bug. If you want to repair your configuration, open the file .idea/mongoSettings.xml and add under <ServerConfiguration> the line <option name="label" value="MyLabel" /> if needed.

eddturtle commented 6 years ago

Ahh! Fantastic, that was it. Checked that file and there was one without a label, added the label, restarted and it works perfectly! (I find this plugin ever so useful, thanks!)

rdev02 commented 6 years ago

Same bug here on High Sierra 10.13.6 (17G65). Tried to manually replace the plugin with snapshot above - did not help. Also, I do not have mongoSettings.xml in ~/Library/Preferences/IdeaVersion.

sturman commented 6 years ago

@rdev02 you can find mongoSettings.xml in .idea folder in your project directory, not in ~/Library/Preferences/IdeaVersion

rdev02 commented 6 years ago

found it. I simply removed it and after I restarted my IDE it started working. Thanks!

eponymz commented 5 years ago

Hello

I am still seeing this NPE stack in DataGrip 2018.2 I have tried the main release version as well as the snapshot version. My server is hosted on mLab.com and the version there is 3.6.6. I did not leave the label blank.

edit installing IntelliJ to test. The program is essentially the same but better safe than sorry.

edit again IntelliJ with the snapshot works. But would be super cool to be able to use this plugin through DataGrip. I can make a formal feature request if that is possible.

jtyoui commented 4 years ago
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="MongoConfiguration">
    <option name="serverConfigurations">
      <list>
        <ServerConfiguration>
          <option name="label" value="demo服务器" />
          <option name="serverUrls">
            <list>
              <option value="172.16.20.xx:27017" />
            </list>
          </option>
          <option name="sshTunnelingConfiguration">
            <SshTunnelingConfiguration />
          </option>
        </ServerConfiguration>
      </list>
    </option>
  </component>
</project>