Repository navigation
Description
Steps to reproduce
- Import a simple Quarkus project (that has an
application.propertiesand various different.javasource files). - Open a few Java source files
- Perform a "save" in any of the source files, even if no actual changes are made.
In the client/server logs you should notice :
logs
[Trace - 15:45:22] Sending notification 'textDocument/willSave'.
Params: {
"textDocument": {
"uri": "file:///home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart/src/main/java/org/acme/config/GreetingResource.java"
},
"reason": 1
}
[Trace - 15:45:22] Sending request 'textDocument/willSaveWaitUntil - (76)'.
Params: {
"textDocument": {
"uri": "file:///home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart/src/main/java/org/acme/config/GreetingResource.java"
},
"reason": 1
}
[Trace - 15:45:22] Received response 'textDocument/willSaveWaitUntil - (76)' in 17ms.
Result: []
[Trace - 15:45:22] Sending notification 'textDocument/didSave'.
Params: {
"textDocument": {
"uri": "file:///home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart/src/main/java/org/acme/config/GreetingResource.java"
},
"text": "......."
}
[Trace - 15:45:22] Sending request 'workspace/executeCommand - (77)'.
Params: {
"command": "microprofile/java/diagnostics",
"arguments": [
{
"uris": [
"file:///home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart/src/test/java/org/acme/config/GreetingResourceIT.java",
"file:///home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart/src/test/java/org/acme/config/GreetingResourceTest.java",
"file:///home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart/src/main/java/org/acme/config/GreetingResource.java"
],
"documentFormat": 2,
"settings": {
"patterns": []
}
}
]
}
[Trace - 15:45:22] Received notification 'textDocument/publishDiagnostics'.
Params: {
"uri": "file:///home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart",
"diagnostics": []
}
[Trace - 15:45:22] Received notification 'textDocument/publishDiagnostics'.
Params: {
"uri": "file:///home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart/pom.xml",
"diagnostics": []
}
[Trace - 15:45:22] Received request 'workspace/executeClientCommand - (35)'.
Params: {
"command": "microprofile/propertiesChanged",
"arguments": [
{
"type": [
1
],
"projectURIs": [
"/home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart"
]
}
]
}
[Trace - 15:45:22] Received response 'workspace/executeCommand - (77)' in 92ms.
Result: [
{
"uri": "file:///home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart/src/test/java/org/acme/config/GreetingResourceIT.java",
"diagnostics": []
},
{
"uri": "file:///home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart/src/test/java/org/acme/config/GreetingResourceTest.java",
"diagnostics": []
},
{
"uri": "file:///home/rgrunber/sample-projects/quarkus-quickstarts/config-quickstart/src/main/java/org/acme/config/GreetingResource.java",
"diagnostics": []
}
]So a save in a single Java source file triggers validation in all other files, even though they all remain unchanged.
Explanation
The reason this happens is because the moment a file is saved, the JDT auto-builder runs and delegates to M2E's builder. M2E runs maven-resources-plugin to copy src/main/resources/ into target/classes/ (as per the Quarkus project pom file) . It seems that plugin is clever enough to distinguish between modification (file content changes) & changes (file metadata changes) but the Eclipse platform makes no distinction. It considers the file has changed if the timestamp for it is different, which it is. It broadcasts a resource change event for the application.properties and ultimately this results in microprofile/propertiesChanged notification being sent back to the MicroProfile LS, which then triggers validation on all files.
This is probably a pure vscode-microprofile issue, but figured I'd report here for a bit more visibility. Also, as a small note, validation on all opened files will still get triggered purely from saving a source file. However, the issues is that validation is being triggered more than it should be.
Solution(s)
Disabling the autobuilder (java.autobuild.enabled to false) is a possible workaround. The issue can't happen if a build doesn't occur on save. Not very ideal though.
The better solution is to store a checksum of the file in order to only call microprofile/propertiesChanged if the properties file has actually changed.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]Autobuild triggers unnnecessary validationof all opened Java source files[/-][+]Autobuild triggers unnnecessary validation of all opened Java source files[/+]angelozerr commentedon Apr 16, 2025
I need to check that, but in IJ Quarkus we have not this problem.
The problem is as you said. Is MP JDT send microprofile/propertiesChanged.
So the fix must be done in MP JDT side to avoid sending a microprofile/propertiesChanged and not in MP LS side.
I have not tested but perhaps the fix is to send a microprofile/propertiesChanged by using a resource listener by tracking the application.properties from src and not from target.
angelozerr commentedon Apr 16, 2025
And I need to investigate again but I wonder if we need this microprofile/propertiesChanged?
Perhaps a fix is to remove this microprofile/propertiesChanged and trigger java validation on didSave of the application.properties on the MP LS side.
angelozerr commentedon May 14, 2025
@rgrunber
means that a Java file has been saved (type is equals to 1)
The problem that I have seen is that when you save a Java file, it validate twice all Java files. Here a trace with 3 opened Java files and a save has been done:
As you can see all opened Java files are validated twice:
I don't remember why a Java save, retrigger validation for all opened Java files (let me investigate that), but the type=3 must never sent to avoid twice validation.
angelozerr commentedon May 14, 2025
@rgrunber please review eclipse-lsp4mp/lsp4mp#500
rgrunber commentedon May 14, 2025
I thought because content in one Java source file could affect content in the others (eg. using API from one file that is used in the other). Same goes for properties file changing. If a properties key/value is removed in a config file, then maybe certain config property annotations from an opened file need a warning about missing value.
I'm sure there's a good reason why we validate. But if we can avoid it for better performance, it may be worth it.
Also, sometimes"diagnostics": []just means that something has requested the diagnostics be cleared.datho7561 commentedon Apr 22, 2026
@angelozerr This is fixed by #546, right?
angelozerr commentedon Apr 22, 2026
Yes it should.
datho7561 commentedon Apr 22, 2026
Fixed by eclipse-lsp4mp/lsp4mp#546