MavenIndexerWrapper () { if (myIndexerWrapper != null) return myIndexerWrapper; synchronized (myMultimoduleDirToConnectorMap) { if (myIndexerWrapper != null) return myIndexerWrapper; String workingDir = SystemUtils.getUserHome().getAbsolutePath(); myIndexerWrapper = new MavenIndexerWrapper(null) { @Override protected MavenIndices createMavenIndices(Project project) { MavenIndices indices = new MavenIndices(this, MavenSystemIndicesManager.getInstance().getIndicesDir().toFile(), project); Disposer.register(MavenDisposable.getInstance(project), indices); return indices; } @Override protected @NotNull MavenServerIndexer create() throws RemoteException { MavenServerConnector indexingConnector = getIndexingConnector(); return indexingConnector.createIndexer(); } @Override protected synchronized void handleRemoteError(RemoteException e) { super.handleRemoteError(e); if (waitIfNotIdeaShutdown()) { MavenIndexingConnectorImpl indexingConnector = myIndexingConnector; if (indexingConnector != null && !indexingConnector.checkConnected()) { shutdownConnector(indexingConnector, true); } } } private MavenServerConnector getIndexingConnector() { if (myIndexingConnector != null) return myIndexingConnector; synchronized (myMultimoduleDirToConnectorMap) { if (myIndexingConnector != null) return myIndexingConnector; myIndexingConnector = new MavenIndexingConnectorImpl(JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk(), "", getFreeDebugPort(), MavenDistributionsCache.resolveEmbeddedMavenHome(), workingDir); myIndexingConnector.connect(); } return myIndexingConnector; } private static boolean waitIfNotIdeaShutdown() { try { Thread.sleep(100); return true; } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } return false; } }; } return myIndexerWrapper; }