Library already disposed when resolving a bunch of modules in external system

已计划

Hello guys,

I'm working on a plugin to resolve Ivy dependencies within IntelliJ. This itself isn't an issue. I'm using the external system API as I like the dependency tree shown there. But, I get problems when resolving a project with a lot of modules (61 to be exact). In my small test environment with some simple modules, the resolve process resolves without any problems. When I test my plugin implementation in my production environment, I see very often that a library is disposed already?

As I understand the stacktrace and the time it happens, as far as I know, I can't take any measures against this to happen, can I? It happens when the IDE successfully called ExternalSystemProjectResolver.resolveProjectInfo(). Could it be a concurrency issue somewhere when all 61 modules gets resolved at once and some finishes at the same time but for different modules? Is there a way to fix the disposing issue of the library object I'm not aware yet?

The external system tree itself works totally fine. The projects and their dependencies are correctly computed and shown. The only problems I actually have happens when the computed dependency trees are synced with the project environment.

Mostly, some modules are removed from the project even though the resolve worked totally fine, the matching of the resolved modules to the module instances with group names doesn't work and "new modules" without any group name gets created and so on.

I don't know, if the issues above are caused because of the disposing issue, but the stacktrace here happens a lot bloating the logs... So, focusing on them for now.

Can someone help with some hints or background info and maybe help me out avoiding them?

ERROR - idge.library.LibraryBridgeImpl - Library LibraryId(name=Ivy: com.github.junrar:junrar:4.0.0, tableId=ModuleLibraryTableId(moduleId=ModuleId(name=MODULE_GROUP.MODULE_NAME))) already disposed:
Library id: LibraryId(name=Ivy: com.github.junrar:junrar:4.0.0, tableId=ModuleLibraryTableId(moduleId=ModuleId(name=MODULE_GROUP.MODULE_NAME)))
Entity: Ivy: com.github.junrar:junrar:4.0.0, 55834574848
Is disposed in project model: true
Stack trace: --------------Creation trace:
java.lang.Throwable
at com.intellij.openapi.util.TraceableDisposable.<init>(TraceableDisposable.java:27)
at com.intellij.workspaceModel.ide.impl.legacyBridge.library.LibraryBridgeImpl.<init>(LibraryBridgeImpl.kt:50)
at com.intellij.workspaceModel.ide.impl.legacyBridge.module.roots.ModuleLibraryTableBridgeImpl.addLibrary(ModuleLibraryTableBridgeImpl.kt:57)
at com.intellij.workspaceModel.ide.impl.legacyBridge.module.roots.ModuleLibraryTableBridgeImpl.registerModuleLibraryInstances(ModuleLibraryTableBridgeImpl.kt:30)
at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerBridgeImpl$loadModules$4.invoke(ModuleManagerBridgeImpl.kt:108)
at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerBridgeImpl$loadModules$4.invoke(ModuleManagerBridgeImpl.kt:45)
at com.intellij.workspaceModel.ide.impl.WorkspaceModelImpl.updateProjectModelSilent(WorkspaceModelImpl.kt:81)
at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerBridgeImpl.loadModules(ModuleManagerBridgeImpl.kt:102)
at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleBridgeLoaderService.loadModules(ModuleBridgeLoaderService.kt:53)
at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleBridgeLoaderService.<init>(ModuleBridgeLoaderService.kt:43)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:52)
at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:876)
at com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:47)
at com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:37)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:113)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:67)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:60)
at com.intellij.serviceContainer.ComponentManagerImpl.instantiateService(ComponentManagerImpl.kt:1044)
at com.intellij.serviceContainer.ComponentManagerImpl$preloadServices$1.invoke(ComponentManagerImpl.kt:1016)
at com.intellij.serviceContainer.ComponentManagerImpl$preloadServices$1.run(ComponentManagerImpl.kt:56)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
--------------Kill trace:
java.lang.Throwable
at com.intellij.openapi.util.TraceableDisposable.kill(TraceableDisposable.java:32)
at com.intellij.workspaceModel.ide.impl.legacyBridge.library.LibraryBridgeImpl.dispose(LibraryBridgeImpl.kt:144)
at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:136)
at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:166)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:169)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:157)
at com.intellij.workspaceModel.ide.impl.legacyBridge.module.roots.ModifiableModuleLibraryTableBridge.disposeOriginalLibrariesAndUpdateCopies$intellij_platform_projectModel_impl(ModifiableModuleLibraryTableBridge.kt:182)
at com.intellij.workspaceModel.ide.impl.legacyBridge.module.roots.ModifiableRootModelBridgeImpl.postCommit(ModifiableRootModelBridgeImpl.kt:544)
at com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl.lambda$workspaceModelCommit$5(IdeModifiableModelsProviderImpl.java:201)
at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.mergeRootsChangesDuring(ProjectRootManagerImpl.java:390)
at com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl.workspaceModelCommit(IdeModifiableModelsProviderImpl.java:136)
at com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl.commit(IdeModifiableModelsProviderImpl.java:132)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl$2.execute(ProjectDataManagerImpl.java:424)
at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:22)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:947)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.lambda$executeProjectChangeAction$5(ExternalSystemApiUtil.java:353)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:348)
at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
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.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
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)
-------------Own trace:
com.intellij.openapi.util.TraceableDisposable$DisposalException: 5923194
at com.intellij.openapi.util.TraceableDisposable.getStackTrace(TraceableDisposable.java:78)
at com.intellij.workspaceModel.ide.impl.legacyBridge.library.LibraryBridgeImpl.checkDisposed(LibraryBridgeImpl.kt:156)
at com.intellij.workspaceModel.ide.impl.legacyBridge.library.LibraryBridgeImpl.getLibrarySnapshot(LibraryBridgeImpl.kt:81)
at com.intellij.workspaceModel.ide.impl.legacyBridge.library.LibraryBridgeImpl.getProperties(LibraryBridgeImpl.kt:111)
at com.intellij.jarRepository.RepositoryLibrarySynchronizer.lambda$collectLibrariesToSync$8(RepositoryLibrarySynchronizer.java:176)
at com.intellij.jarRepository.RepositoryLibrarySynchronizer.lambda$collectLibraries$0(RepositoryLibrarySynchronizer.java:67)
at com.intellij.openapi.roots.impl.OrderEnumeratorBase.lambda$forEachLibrary$1(OrderEnumeratorBase.java:347)
at com.intellij.openapi.roots.impl.OrderEnumeratorBase.processEntries(OrderEnumeratorBase.java:310)
at com.intellij.openapi.roots.impl.ModuleOrderEnumerator.forEach(ModuleOrderEnumerator.java:33)
at com.intellij.openapi.roots.impl.OrderEnumeratorBase.forEachLibrary(OrderEnumeratorBase.java:343)
at com.intellij.openapi.roots.impl.ModuleOrderEnumerator.forEachLibrary(ModuleOrderEnumerator.java:17)
at com.intellij.jarRepository.RepositoryLibrarySynchronizer.lambda$collectLibraries$1(RepositoryLibrarySynchronizer.java:66)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:839)
at com.intellij.jarRepository.RepositoryLibrarySynchronizer.collectLibraries(RepositoryLibrarySynchronizer.java:62)
at com.intellij.jarRepository.RepositoryLibrarySynchronizer.collectLibrariesToSync(RepositoryLibrarySynchronizer.java:173)
at com.intellij.jarRepository.RepositoryLibrarySynchronizer.syncLibraries(RepositoryLibrarySynchronizer.java:161)
at com.intellij.jarRepository.RepositoryLibrarySynchronizer.lambda$runActivity$5(RepositoryLibrarySynchronizer.java:141)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:240)
at com.intellij.util.Alarm$Request.runSafely(Alarm.java:385)
at com.intellij.util.Alarm$Request.run(Alarm.java:374)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:220)
at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:246)
at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:32)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.execute(BoundedTaskExecutor.java:225)
at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:213)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:214)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:829)
0

Hi, what version of IJ do you use? Could you please also attach the log (https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files) file?
Do you have a project with this exception that is open-source or can be shared?

0

Hi, I'm created a project looking similar to the production one I typically use with 59 modules all using Ivy to resolve dependencies. You can download it here: https://www.dropbox.com/s/gt16mpfzpz5pz2n/Ivy-Test-Environment.zip

The logs are available at: https://www.dropbox.com/s/if09bmmer3wv4uf/log.zip

The logs contains a clean start of IntelliJ IDEA Ultimate 2021.3 (I have problems with 2021.2.x, too) with the import of the modules. After the successful import, I simply triggered a re-import of all ivy projects via the external system. Depending on your luck, a refresh call might also corrupt the IJ settings so a bubble pops up, telling me to restart IJ as it's corrupt now and can't save any changes anymore. This isn't included in the logs here.

My plugin you can find here: https://github.com/Xeonkryptos/ivyidea/tree/feature/external-system. As I'm still working on it, I'm building it locally and install it from filesystem afterwards or use the sandbox instance.

0

请先登录再写评论。