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

Catch runtime exceptions to make class loader race conditions easier to debug. #608

Merged
merged 1 commit into from
May 10, 2021

Conversation

dblock
Copy link
Member

@dblock dblock commented Apr 23, 2021

Signed-off-by: dblock dblock@amazon.com

Description

Not sure we need this, but thought I'd PR anyway.

I came from opensearch-project/anomaly-detection#15 to find that the issue was fixed in #604. However, it took me a while to wrap my head around the problem and to find the explanation buried inside a comment: https://github.com/opensearch-project/OpenSearch/pull/604/files#r618861212. The root cause is a class loader race condition, where the static block requires fields of LegacyESVersion to be non-null, but Version is loaded before LegacyESVersion, since LegacyESVersion inherits from Version. Kudos @nknize for spotting this.

Before this change you would get a NullPointerException error.

    java.lang.ExceptionInInitializerError
        at org.opensearch.index.store.StoreStats.<clinit>(StoreStats.java:54)
        at jdk.internal.reflect.GeneratedSerializationConstructorAccessor14.newInstance(Unknown Source)
        ...

        Caused by:
        java.lang.NullPointerException
            at org.opensearch.Version.<clinit>(Version.java:114)
            ... 22 more

With this change you can at least see which field is causing the problem.

  2> java.lang.AssertionError: Version field [V_6_0_0_alpha1] threw [java.lang.NullPointerException] during initialization
        at org.opensearch.Version.<clinit>(Version.java:121)
        at org.opensearch.index.store.StoreStats.<clinit>(StoreStats.java:54)

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…to debug.

Signed-off-by: dblock <dblock@amazon.com>
@odfe-release-bot
Copy link

✅   Gradle Wrapper Validation success 8356f24

@odfe-release-bot
Copy link

✅   DCO Check Passed 8356f24

@odfe-release-bot
Copy link

✅   Gradle Precommit success 8356f24

@dblock
Copy link
Member Author

dblock commented May 5, 2021

start gradle check

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 8356f24
Log 163

Reports 163

Copy link
Contributor

@adnapibar adnapibar left a comment

Choose a reason for hiding this comment

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

LGTM

@dblock dblock merged commit 58f9aac into opensearch-project:main May 10, 2021
abbashus added a commit that referenced this pull request May 21, 2021
…to debug. (#608) (#750)

Signed-off-by: dblock <dblock@amazon.com>

Co-authored-by: Daniel Doubrovkine (dB.) <dblock@dblock.org>
ritty27 pushed a commit to ritty27/OpenSearch that referenced this pull request May 12, 2024
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
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