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

Attempt to detect host environments (like unforked sbt) #2719

Merged
merged 2 commits into from
Jan 3, 2022

Conversation

djspiewak
Copy link
Member

@djspiewak djspiewak commented Jan 1, 2022

Rather than printing and calling System.exit, we just throw whenever we're not forked. The detection here actually seems robust enough to lean on, particularly since the degradation path is fine. This also has the pleasing side effect of integrating better with sbt's last command.

Fixes #2706

@djspiewak djspiewak linked an issue Jan 1, 2022 that may be closed by this pull request
@djspiewak djspiewak merged commit 0f5c168 into typelevel:series/3.3.x Jan 3, 2022
@@ -200,6 +200,9 @@ trait IOApp {
def run(args: List[String]): IO[ExitCode]

final def main(args: Array[String]): Unit = {
// checked in openjdk 8-17; this attempts to detect when we're running under artificial environments, like sbt
Copy link

Choose a reason for hiding this comment

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

Does this comment mean that this has been tested on those Java versions? I'm on Java 23, and Thread.currentThread().getId() returns 1 - though that .getId() got deprecated in Java 19, because:

This method is not final and may be overridden to return a value that is not the thread ID. Use threadId() instead

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

Successfully merging this pull request may close these issues.

Errors raised in unforked IOApps terminate sbt 1.6.x
4 participants