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

Make PositionImpl thread-safe #465

Merged
merged 1 commit into from
Dec 9, 2017
Merged

Make PositionImpl thread-safe #465

merged 1 commit into from
Dec 9, 2017

Conversation

eed3si9n
Copy link
Member

@eed3si9n eed3si9n commented Dec 6, 2017

Fixes #464
Fixes sbt/sbt#3623

Currently, compiling a lot of Java code in CI environment causes NullPointerException, which is
suspected of race condition around javax.tools.Diagnostics[S], which is held by PositionImpl and then later accessed by async logging.

This change makes the PositionImpl strict and immutable, and extracts it from a Java Diagnostics object. No other observable changes are introduced besides, hopefully the lack of NPE. Credit on the detective work goes to Lightbend Akka team @ktoso, @2m, and @jrudolph.

dwijnand
dwijnand previously approved these changes Dec 6, 2017
Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

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

LGTM, one question.

}
} catch {
// TODO - catch ReflectiveOperationException once sbt is migrated to JDK7
case ignored: Throwable => None
Copy link
Member

Choose a reason for hiding this comment

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

Should we postpone this change for an RC cycle?

Copy link
Member Author

Choose a reason for hiding this comment

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

You have a hawk eye. Sure, I'll be fine with moving that change to 1.1.x.

Copy link
Member

Choose a reason for hiding this comment

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

It's clearer when ignoring whitespace changes: https://github.com/sbt/zinc/pull/465/files?w=1.

dwijnand
dwijnand previously approved these changes Dec 6, 2017
Copy link
Member

@jrudolph jrudolph left a comment

Choose a reason for hiding this comment

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

I guess that will fix the bug, but what should really be fixed is the underlying logging infrastructure, otherwise this will come back in another form.

@jvican
Copy link
Member

jvican commented Dec 7, 2017

Reviewing this tomorrow.

Copy link
Member

@jvican jvican left a comment

Choose a reason for hiding this comment

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

LGTM, just one minor request and it's good to go.

/**
* Strict and immutable implementation of Position.
*/
private[sbt] final class PositionImpl(
Copy link
Member

Choose a reason for hiding this comment

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

If we're only going to instantiate this class via its apply method in the companion, could we make this constructor private?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion. I'll make the change.

Fixes sbt#464 sbt/sbt#3623

Currently compiling a lot of Java code in CI environment causes NullPointerException, which is
suspected of race condition around `javax.tools.Diagnostics[S]`, which is held by `PositionImpl` and then later accessed by async logging.

This change makes the `PositionImpl` strict and immutable, and extracts it from a Java Diagnostics object. No other observable changes are introduced besides, hopefully the lack of NPE. Credit on the detective work goes to Lightbend Akka team ktoso, 2m, and jrudolph.
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.

4 participants