Skip to content

Avoid re-using same job #2356

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

Merged
merged 1 commit into from
Nov 30, 2022
Merged

Conversation

mickaelistria
Copy link
Contributor

Modifying a running or just cancelled job is not always a safe operation. This can (does when integrated in Eclipse IDE) lead to IllegalStateException when calling getRule() on some already scheduled job.
To prevent that, just create a new job when rules change.

@snjeza
Copy link
Contributor

snjeza commented Nov 30, 2022

test this please

@rgrunber
Copy link
Contributor

@snjeza , I see a lot of places in the tests where we use the DocumentAdapter instead of returning the compilation unit's buffer. Also at

https://github.com/eclipse/eclipse.jdt.ls/blob/e7e1418bca69e6d5862ea4e90c1c80ce55c711b1/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/commands/DiagnosticsCommand.java#L109

Is this change safe to do ?

@mickaelistria
Copy link
Contributor Author

The part in createBuffer is not related to the intent of this change. I'll remove it.

Modifying a running or just cancelled job is not always a safe
operation. This can (does when integrated in Eclipse IDE) lead to
IllegalStateException when calling getRule() on some already scheduled
job.
To prevent that, just create a new job when rules change.
@mickaelistria
Copy link
Contributor Author

Done removing unrelated part of this PR.

@rgrunber rgrunber added this to the End November milestone Nov 30, 2022
@rgrunber rgrunber added the bug label Nov 30, 2022
@rgrunber

This comment was marked as outdated.

1 similar comment
@rgrunber
Copy link
Contributor

re-test this please.

@rgrunber
Copy link
Contributor

@mickaelistria , just wondering, we re-use validationTimer, in the same way. Did you not encounter any issues with that ?

@rgrunber
Copy link
Contributor

re-test this please.

1 similar comment
@rgrunber
Copy link
Contributor

re-test this please.

@rgrunber rgrunber merged commit bfea879 into eclipse-jdtls:master Nov 30, 2022
@snjeza
Copy link
Contributor

snjeza commented Dec 1, 2022

I see a lot of places in the tests where we use the DocumentAdapter instead of returning the compilation unit's buffer. Also at
...
Is this change safe to do ?

@rgrunber It is copied from https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/567c1546ee76fbbd4a50ee6b0de8e046a19356fe/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/DocumentAdapter.java
Eclipse JDT Team uses it in their tests too.

@mickaelistria
Copy link
Contributor Author

Did you not encounter any issues with that ?

Not with this one.
My impression is that the cancel didn't take immediate effect as expected for the publishDiagnosticsJob. Either it was not performed at all, or maybe it was rescheduled automatically for some reason (some job listener?) before the setRule in invoked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants