-
Notifications
You must be signed in to change notification settings - Fork 281
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
call close() on compiler in scalacWorker after each job #1504
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @crt-31! Please address style related comments
|
||
public class ReportableMainClass extends MainClass { | ||
private Reporter reporter; | ||
private final CompileOptions ops; | ||
private Global _compiler = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: uncommon in Java style to prefix private vars with underscore - please rename to compiler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
|
||
public ReportableMainClass(CompileOptions ops) { | ||
this.ops = ops; | ||
} | ||
|
||
public void Close() throws Exception{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: don't start method names with a capital letter. Please rename to close()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Description
This PR fixes the scalacWorker so that it calls close() on the compiler object (nsc.Global) after each job is done. This allows file resources (i.e. dependent jar files, source files, etc) that the compiler uses to be properly released after each job.
Note that nsc.Global did not add the close() functionality until v2.12. This is handled in this PR.
Motivation
This issue was noticed more on Windows since Windows will lock the file (and not allow edits) until it is released. And with scalacWorker being a persistent process, it would lock the files until you called “bazel shutdown”.
This should resolve #1486, where this issue was causing *-ijar.jar handles not to be released.
Aside: There is still an issue where the jars for plugins are not being released (because calling nsc.Global.close() does not release the plugins). This is probably more of a Bazel core issue where Bazel needs to stop the workers when any plugins (or other tooling used by the worker) need to be recompiled. The related issue is Bazel issue #10498.