Skip to content

Don't re-trigger Java validation for all opened Java files when a Java file is saved.#546

Merged
datho7561 merged 1 commit into
eclipse-lsp4mp:masterfrom
angelozerr:fix_retriger_validation
Apr 22, 2026
Merged

Don't re-trigger Java validation for all opened Java files when a Java file is saved.#546
datho7561 merged 1 commit into
eclipse-lsp4mp:masterfrom
angelozerr:fix_retriger_validation

Conversation

@angelozerr
Copy link
Copy Markdown
Contributor

@angelozerr angelozerr commented Apr 21, 2026

Don't re-trigger Java validation for all opened Java files when a Java file is saved.

This PR avoid sending (type=3 which means configFile changed)

[Trace - 9:33:16 PM] Sending notification 'microprofile/propertiesChanged'.
Params: {
    "type": [
        3
    ],
    "projectURIs": [
        "C:\\Users\\azerr\\Downloads\\demo\\demo"
    ]
}

which retriggers validation of Java files when a Java file is saved.

See redhat-developer/vscode-quarkus#1004 (comment)

Before this PR

  • when Java file was saved, 'microprofile/propertiesChanged' was sent because target/classes/application.properties was updated
  • when src/main/resources/application.properties, 'microprofile/propertiesChanged' was sent twice (one update from src/main/resources/application.properties and one update from target/classes/application.properties

After this PR

  • when Java file is saved, no 'microprofile/propertiesChanged' should be sent.
  • when src/main/resources/application.properties is saved, only one 'microprofile/propertiesChanged' should be sent

file is saved.

Signed-off-by: azerr <azerr@redhat.com>
@angelozerr angelozerr changed the title Don't re-trigger Java validation for all opened Java files when a Java Don't re-trigger Java validation for all opened Java files when a Java file is saved. Apr 21, 2026
@angelozerr angelozerr self-assigned this Apr 21, 2026
@angelozerr angelozerr added the bug Something isn't working label Apr 21, 2026
@angelozerr angelozerr added this to the 0.16.1 milestone Apr 21, 2026
@angelozerr angelozerr requested a review from datho7561 April 21, 2026 13:25
JDTMicroProfileProject mpProject = getJDTMicroProfileProject(file);
if (mpProject != null) {
// Evict the properties cache
mpProject.evictConfigSourcesCache();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was super annoying because it evicted the config source cache as soon as an application.properties was updated (in other words when a Java file was saved because target/classes/application.properties was updated) or when src/main/resources/application.properties was updated.

// Create, delete config source file (ex : microprofile-config.properties)
if (mpProject != null) {
// Evict the properties cache
mpProject.evictConfigSourcesCache();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The evict cache of config source is done now only when a config file is created/deleted which is required to rebuild the config files scope.

}
} else if (isFileContentChanged(delta)) {
// Update config source file (ex : microprofile-config.properties)
generateEvent = mpProject != null ? mpProject.updateConfigSource(file) : true;
Copy link
Copy Markdown
Contributor Author

@angelozerr angelozerr Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case comes from when:

  • a Java file is saved, target/application.properties is updated.
  • src/main/resources/application.properties is updated.

The mpProject.updateConfigSource(file) returns true only when src/main/resources/application.properties is updated

When application.properties is updated (only for sources), we don't evict the full cache of config sources but just reset the IConfigSource

Copy link
Copy Markdown
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and makes sense. Thanks, Angelo!

@datho7561 datho7561 merged commit b4a4bfd into eclipse-lsp4mp:master Apr 22, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants