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

Fix: (move and) make get_thread_id "nil safe" #11458

Closed
wants to merge 4 commits into from

Conversation

kares
Copy link
Contributor

@kares kares commented Dec 23, 2019

necessary since native (Java) thread is kept as a weak ref
so un-wrapping should deal with a potentially GCd instance

resolves GH-11450

@amitavmohanty01
Copy link
Contributor

Can you please backport to 7.4.3 release as well?

necessary since native (Java) thread is kept as a weak ref
so un-wrapping should deal with a potentially GCd instance

resolves elasticGH-11450
@kares
Copy link
Contributor Author

kares commented Dec 30, 2019

there isn't another 7.4 release planned atm, this might end up in 7.5.2 or otherwise at 7.6.0

@elasticsearch-bot elasticsearch-bot self-assigned this Dec 30, 2019
@@ -37,18 +35,10 @@ def self.set_thread_plugin(plugin)
Thread.current[:plugin] = plugin
end

def self.get_thread_id(thread)
if RUBY_ENGINE == "jruby"
JRuby.reference(thread).native_thread.id
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the reason for moving the method to native is the JRuby.reference usage.
... a bit unfortunate API as it has side effects on (self) reflecting JRuby's Java classes
as of the date having this classes present some issues at runtime e.g. when looping through Class objects

@andsel
Copy link
Contributor

andsel commented Dec 30, 2019

LGTM

@andsel andsel self-requested a review December 30, 2019 11:53
@andsel andsel assigned kares and unassigned elasticsearch-bot Dec 30, 2019
@elasticsearch-bot
Copy link

Karol Bucek merged this into the following branches!

Branch Commits
master 850d270, b9fb9a7, 7b4e358, 18af2d2
7.x 51de4c2, 32c306f, fd36783, ded1749
7.5 57facfd, 598e75a, 914577b, 15e7b27

elasticsearch-bot pushed a commit that referenced this pull request Dec 30, 2019
(other part of same method assume JRuby already)

Fixes #11458
elasticsearch-bot pushed a commit that referenced this pull request Dec 30, 2019
elasticsearch-bot pushed a commit that referenced this pull request Dec 30, 2019
necessary since native (Java) thread is kept as a weak ref
so un-wrapping should deal with a potentially GCd instance

resolves GH-11450

Fixes #11458
elasticsearch-bot pushed a commit that referenced this pull request Dec 30, 2019
elasticsearch-bot pushed a commit that referenced this pull request Dec 30, 2019
elasticsearch-bot pushed a commit that referenced this pull request Dec 30, 2019
necessary since native (Java) thread is kept as a weak ref
so un-wrapping should deal with a potentially GCd instance

resolves GH-11450

Fixes #11458
elasticsearch-bot pushed a commit that referenced this pull request Dec 30, 2019
elasticsearch-bot pushed a commit that referenced this pull request Dec 30, 2019
(other part of same method assume JRuby already)

Fixes #11458
elasticsearch-bot pushed a commit that referenced this pull request Dec 30, 2019
elasticsearch-bot pushed a commit that referenced this pull request Dec 30, 2019
necessary since native (Java) thread is kept as a weak ref
so un-wrapping should deal with a potentially GCd instance

resolves GH-11450

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

Successfully merging this pull request may close these issues.

Native threads are nil
4 participants