Only apply TracePoint to current thread #759
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
While upgrading to webmock 3.4.0 I found that some of my specs started failing. The way my tests are setup, in addition to using webmock for stubbing out requests in unit tests I also perform integration tests by making unmocked http requests against a WEBRick server running in a different thread in my rspec process.
After a bit of debugging I've narrowed the issue down to the TracePoint code added in #751 not being thread safe. In particular that code will undefine any local variable called
tmp
whenever any line of code is run in any thread, even not in therbuf_fill
thread for which it was intended.The end result is I would get exceptions in places like webrick/log.rb#L152:
With errors on
tmp << " "
likeundefined method '<<' for nil:NilClass (NoMethodError)
(despitetmp
having been immediately defined the line before).Or webrick/httputils.rb#L211:
My fix is to apply the tracepoint only to the
rbuf_fill
thread - after applying this change locally all my tests pass without exception.Thanks
edit: I believe the
jruby-9.0.5.0
failure on travis is unrelated to my change