eclipse.jdt.ls icon indicating copy to clipboard operation
eclipse.jdt.ls copied to clipboard

When doing several requests in parallel , getting a wrong result

Open yuval-piiano opened this issue 2 years ago • 5 comments

I am making several documentSymbol requests in parallel to the jdt, and once in a while I am getting an empty result (for a file which has symbols) and a logMessage error

`2022-12-11T14:41:06.5325181Z {"asctime": "2022-12-11 14:41:06,515", "pathname": "/runner/_work/.tox/py39/lib/python3.9/site-packages/code_scan_lsp/lsp_services/lsp_wrapper.py", "funcName": "status_callback", "name": "code_scan_lsp.lsp_services.lsp_wrapper", "lineno": 47, "process": 826, "message": "window/logMessage {'type': 1, 'message': "Dec 11, 2022, 2:41:06 PM Failed to create linked resource from file:///runner/_work//temp/71bdc0c9-c095-40c5-a8c4-c5572c44ec03/sm-core-model/src/main/java/com/salesmanager/core/model/user/UserCriteria.java to jdt.ls-java-project\nResource '/jdt.ls-java-project/src/com/salesmanager/core/model/user' already exists.\norg.eclipse.core.internal.resources.ResourceException(/jdt.ls-java-project/src/com/salesmanager/core/model/user)[374]: java.lang.Exception: Resource '/jdt.ls-java-project/src/com/salesmanager/core/model/user' already exists.\n\tat org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42)\n\tat org.eclipse.core.internal.resources.ResourceException.(ResourceException.java:38)\n\tat org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:309)\n\tat org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:296)\n\tat org.eclipse.core.internal.resources.Folder.assertCreateRequirements(Folder.java:33)\n\tat org.eclipse.core.internal.resources.Folder.create(Folder.java:94)\n\tat org.eclipse.core.internal.resources.Folder.create(Folder.java:122)\n\tat org.eclipse.jdt.ls.core.internal.JDTUtils.createFolders(JDTUtils.java:291)\n\tat org.eclipse.jdt.ls.core.internal.JDTUtils.getFakeCompilationUnit(JDTUtils.java:272)\n\tat org.eclipse.jdt.ls.core.internal.JDTUtils.resolveCompilationUnit(JDTUtils.java:188)\n\tat org.eclipse.jdt.ls.core.internal.JDTUtils.resolveTypeRoot(JDTUtils.java:448)\n\tat org.eclipse.jdt.ls.core.internal.JDTUtils.resolveTypeRoot(JDTUtils.java:407)\n\tat org.eclipse.jdt.ls.core.internal.handlers.DocumentSymbolHandler.documentSymbol(DocumentSymbolHandler.java:74)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$14(JDTLanguageServer.java:679)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:79)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)\n\tat java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)\n\tat java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)\n"}",

Any way to handle this error?

yuval-piiano avatar Dec 12 '22 10:12 yuval-piiano

Resource '/jdt.ls-java-project/src/com/salesmanager/core/model/user' already exists.

What does your project look like? Are you trying to open the same-named class with different disk location?

jdneo avatar Dec 13 '22 01:12 jdneo

This is the project I work on : https://github.com/shopizer-ecommerce/shopizer

I basically create a thread pool of 40 threads and passed all source files and this error happens inconsistently. If I submit each file several times, it always happens (for different files each time) .

yuval-piiano avatar Dec 13 '22 08:12 yuval-piiano

How do you import your project?

jdt.ls-java-project is used to hold files which does not belongs to the current workspace, which means the project is not imported correctly.

jdneo avatar Dec 15 '22 01:12 jdneo

This is my command to start the jdt ls:

java -Xmx3G -noverify -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044 -Dlog.protocol=true -Dlog.level=ALL -javaagent:/source/lombok.jar -jar plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar -configuration /config_mac -data /runner/_work/temp/71bdc0c9-c095-40c5-a8c4-c5572c44ec03 --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED

I then do an initialization request with the following parameters:

{'processId': 43990, 'rootPath': '/runner/_work/temp/71bdc0c9-c095-40c5-a8c4-c5572c44ec03', 'rootUri': 'file:///runner/_work/temp/71bdc0c9-c095-40c5-a8c4-c5572c44ec03', 'initializationOptions': {'extendedClientCapabilities': {'classFileContentsSupport': True}, 'bundles': [], 'workspaceFolders': [], 'settings': {'java': {'references': {'includeAccessors': True}, 'import': {'maven': {'auto': {'sync': True}, 'enabled': False, 'offline': {'enabled': False}}, 'gradle': {'auto': {'sync': True}, 'enabled': False, 'offline': {'enabled': False}}}}}}, 'capabilities': {'textDocument': {'codeAction': {'dynamicRegistration': True}, 'codeLens': {'dynamicRegistration': True}, 'colorProvider': {'dynamicRegistration': False}, 'completion': {'completionItem': {'commitCharactersSupport': False, 'documentationFormat': ['markdown', 'plaintext'], 'snippetSupport': True}, 'completionItemKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}, 'contextSupport': True, 'dynamicRegistration': True}, 'definition': {'dynamicRegistration': True}, 'documentHighlight': {'dynamicRegistration': True}, 'documentLink': {'dynamicRegistration': True}, 'documentSymbol': {'dynamicRegistration': True, 'hierarchicalDocumentSymbolSupport': True, 'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, 'formatting': {'dynamicRegistration': False}, 'hover': {'contentFormat': ['markdown', 'plaintext'], 'dynamicRegistration': False}, 'implementation': {'dynamicRegistration': True}, 'onTypeFormatting': {'dynamicRegistration': False}, 'publishDiagnostics': {'relatedInformation': True}, 'rangeFormatting': {'dynamicRegistration': False}, 'references': {'dynamicRegistration': True}, 'rename': {'dynamicRegistration': False}, 'signatureHelp': {'dynamicRegistration': False, 'signatureInformation': {'documentationFormat': ['markdown', 'plaintext']}}, 'synchronization': {'didSave': True, 'dynamicRegistration': False, 'willSave': True, 'willSaveWaitUntil': True}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': False}}, 'workspace': {'applyEdit': True, 'configuration': True, 'didChangeConfiguration': {'dynamicRegistration': False}, 'didChangeWatchedFiles': {'dynamicRegistration': False}, 'executeCommand': {'dynamicRegistration': False}, 'symbol': {'dynamicRegistration': True, 'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, 'workspaceEdit': {'documentChanges': True}, 'workspaceFolders': True}}, 'trace': 'verbose', 'workspaceFolders': [{'name': 'python-lsp', 'uri': 'file:///runner/_work/temp/71bdc0c9-c095-40c5-a8c4-c5572c44ec03'}]}

When I am getting the message:

language/status {'type': 'ServiceReady', 'message': 'ServiceReady'}

I am starting to loop over the java files in the folder and requesting their symbols. When this is done by a single thread everything passes, but if It is done by a thread queue with more than one thread, sometimes one fails. To induce more failure, If I have each file passed more than once (doing more than one symbols request in it) by the thread queue, I get more failures like this.

yuval-piiano avatar Dec 15 '22 08:12 yuval-piiano

I just reproduced this. It involved import the project / cleaning workspace and switching in between Lightweight / Standard modes. Also seems similar to https://github.com/eclipse-jdtls/eclipse.jdt.ls/issues/638 .

[Error - 12:39:05] May 29, 2024, 12:39:05 p.m. Failed to create linked resource from file:///home/rgrunber/sample-projects/maven-my-app/src/main/java/com/mycompany/app/App.java to jdt.ls-java-project
Resource '/jdt.ls-java-project/src/com' already exists.
org.eclipse.core.internal.resources.ResourceException(/jdt.ls-java-project/src/com)[374]: java.lang.Exception: Resource '/jdt.ls-java-project/src/com' already exists.
	at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42)
	at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:38)
	at org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:343)
	at org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:330)
	at org.eclipse.core.internal.resources.Folder.assertCreateRequirements(Folder.java:40)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:101)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:129)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.createFolders(JDTUtils.java:316)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.createFolders(JDTUtils.java:313)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.createFolders(JDTUtils.java:313)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.getFakeCompilationUnit(JDTUtils.java:297)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.resolveCompilationUnit(JDTUtils.java:199)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.resolveTypeRoot(JDTUtils.java:473)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.resolveTypeRoot(JDTUtils.java:432)
	at org.eclipse.jdt.ls.core.internal.handlers.DocumentSymbolHandler.documentSymbol(DocumentSymbolHandler.java:108)
	at org.eclipse.jdt.ls.core.internal.syntaxserver.SyntaxLanguageServer.lambda$5(SyntaxLanguageServer.java:339)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

rgrunber avatar May 29 '24 16:05 rgrunber