Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GITHUB-6970] MultiSourceRootProvider: reduce logging verbosity #6975

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

matthiasblaesing
Copy link
Contributor

The ClassPathProvider is also invoked for files that are only temporary present. The files are only present for a short time and between the FileObject#isValid call and the FileObject#asBytes call the file is removed leading to an IOException.

This situation is a race condition and happens often enough for users to be annoyed. As this is common and the scanning error is not fatal for normal operation, this should normally not be reported.

Closes: #6970

The ClassPathProvider is also invoked for files that are only temporary
present. The files are only present for a short time and between the
FileObject#isValid call and the FileObject#asBytes call the file is
removed leading to an IOException.

This situation is a race condition and happens often enough for users
to be annoyed. As this is common and the scanning error is not fatal
for normal operation, this should normally not be reported.

Closes: apache#6970
@matthiasblaesing matthiasblaesing added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Jan 18, 2024
@matthiasblaesing matthiasblaesing added this to the NB21 milestone Jan 18, 2024
@lahodaj
Copy link
Contributor

lahodaj commented Jan 18, 2024

I don't have anything against this - I'll leave on others whether it is this or #6974.

@matthiasblaesing
Copy link
Contributor Author

@ebarboni could you give the build from this PR a spin?

Direct link: https://github.com/apache/netbeans/suites/19918053727/artifacts/1179052372

@neilcsmith-net
Copy link
Member

Thanks @matthiasblaesing

@lahodaj I assume you'd want this merged either way given the potential for a race condition here when it's enabled? Should this be mitigated in other ways, or is it always benign? Are file deletions meant to be allowed during parsing?

Should this provider also be filtering something similar to https://github.com/apache/netbeans/blob/master/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java#L183 ??

@ebarboni
Copy link
Contributor

@matthiasblaesing no more popup and nothing on the log (expected as fine)

@lahodaj
Copy link
Contributor

lahodaj commented Jan 19, 2024

Thanks @matthiasblaesing

@lahodaj I assume you'd want this merged either way given the potential for a race condition here when it's enabled?

Yes, lets go with this.

Should this be mitigated in other ways, or is it always benign? Are file deletions meant to be allowed during parsing?

Its all asynchronous, so it may happen. But, normally it wasn't happening all that much so far.

Should this provider also be filtering something similar to https://github.com/apache/netbeans/blob/master/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java#L183 ??

Yes, we probably want something like this, good catch!

Thanks!

@matthiasblaesing
Copy link
Contributor Author

@neilcsmith-net @lahodaj I added a commit that should implement your suggestion.
@ebarboni thanks for testing!

Copy link
Contributor

@lahodaj lahodaj 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 to me, thanks!

Copy link
Member

@mbien mbien 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. Sorry for the delay - super busy.

is the consensus that we should merge this instead of disabling the feature via #6974? I would be ok with this since we can still disable it if something else shows up before RC3.

Comment on lines +85 to +96
if (file == null) {
return false;
}
try {
return !MultiSourceRootProvider.DISABLE_MULTI_SOURCE_ROOT &&
FileOwnerQuery.getOwner(file) == null &&
!file.getFileSystem().isReadOnly();
FileObject dir = file.getParent();
File dirFile = dir != null ? FileUtil.toFile(dir) : null;
return !MultiSourceRootProvider.DISABLE_MULTI_SOURCE_ROOT
&& FileOwnerQuery.getOwner(file) == null
&& !file.getFileSystem().isReadOnly()
&& !(dirFile != null
&& dirFile.getName().startsWith("vcs-")
&& dirFile.getAbsolutePath().startsWith(System.getProperty("java.io.tmpdir")));
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: this growing chain of seemingly unrelated conditions might look better when torn apart into multiple checks:

if (file == null || MultiSourceRootProvider.DISABLE_MULTI_SOURCE_ROOT) {
    return false;
}

try {
    if (fileConditionsFail)
        return false,
    }
    File dirFile = ...
    if (parentConditionsFail) {
        return false;
    }
    return true;

@matthiasblaesing
Copy link
Contributor Author

I advise to merge as is. I think we reached consensus, that this improves the situation. I think the discussion about the styling/structuring of the if-block can happen, but I also think it is no helpful for the release process.

@neilcsmith-net neilcsmith-net merged commit 14a7674 into apache:delivery Jan 22, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants