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

9k Constant Lookup Failure when Curly Brackets Used #4637

Closed
andrewvc opened this issue May 31, 2017 · 6 comments
Closed

9k Constant Lookup Failure when Curly Brackets Used #4637

andrewvc opened this issue May 31, 2017 · 6 comments

Comments

@andrewvc
Copy link

andrewvc commented May 31, 2017

When running https://github.com/logstash-plugins/logstash-input-http_poller on revision b141885e1eeb712e7149b54571639ee5bc58a5bd rspec fails when running bundle exec rspec spec with:

     NameError:
       uninitialized constant RSpec::Matchers::BuiltIn::RaiseError
       Did you mean?  RSpec::Matchers::BuiltIn::RaiseError
                      RangeError

All tests pass when run individually, but the suite consistently fails on both my laptop and on travis CI. The failures can be worked around by switching the syntax from

expect { ..code..}.to raise_error
to
expect do; ..code.. end.to raise_error

which I have done in logstash-plugins/logstash-input-http_poller#71

If I put in a binding.pry right after the exception is triggered the constant is found. This does not happen on JRuby 1.7.26.

Environment info:

JRuby
jruby 9.1.10.0 (2.3.3) 2017-05-25 b09c48a Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [darwin-x86_64]
OS
Darwin andrewvc-elastic 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
andrewvc added a commit to andrewvc/logstash-input-http_poller that referenced this issue May 31, 2017
I reported this bug here: jruby/jruby#4637
By rephrasing these tests we don't trigger this JRuby issue.
@andrewvc
Copy link
Author

Apparently my workaround with do end did not fix it in travis, but did fix it locally on my macbook: https://travis-ci.org/logstash-plugins/logstash-input-http_poller/jobs/238068792

I'm stumped as to how to actually fix this

@headius
Copy link
Member

headius commented May 31, 2017

Braces versus do/end should not make any difference, nor should environment. I suspect there's some dependency-loading issue here, like on one env things are loading in a different order and failing.

Can you narrow down what's actually failing in the app?

andrewvc added a commit to andrewvc/logstash-input-http_poller that referenced this issue Jun 1, 2017
@andrewvc
Copy link
Author

andrewvc commented Jun 1, 2017

@headius you're right, I just got lucky playing the roulette wheel when I changed the braces. It looks like it's something to do with require in rspec that's causing the bug.

If I add require 'rspec/matchers/built_in/raise_error.rb' to the top of my _spec file that seems to fix it.

It looks like the requires should be happening here: https://github.com/rspec/rspec-expectations/blob/master/lib/rspec/matchers.rb#L8 which brings us to:
https://github.com/rspec/rspec-support/blob/3-6-maintenance/lib/rspec/support.rb#L14

While that code is a bit convoluted I don't see anything that seems unsafe there.

BTW, I don't know if you noticed this @headius , but in the error it says:

uninitialized constant RSpec::Matchers::BuiltIn::RaiseError
       Did you mean?  RSpec::Matchers::BuiltIn::RaiseError

So it seems like JRuby simultaneously knows the constant exists, and doesn't know it exists, since the recommendation is for the thing that is missing! Any ideas?

@headius
Copy link
Member

headius commented Jun 1, 2017

I assume there's not a lot of concurrency in the specs, right?

Do they run in some randomize order?

andrewvc added a commit to andrewvc/logstash-input-http_poller that referenced this issue Jun 1, 2017
@andrewvc
Copy link
Author

andrewvc commented Jun 1, 2017

@headius they are randomized but not concurrent. Some of the specs may spawn additional threads, but the actual expectations are all in main.

The confusing thing to me is that my reading of the rspec code indicates that that the require should happen correctly at that point. Additionally, I can access that constant before the specs run. I suspect that if I replaced my duplicate require with a reference to RSpec::Matchers::BuiltIn::RaiseError that would work as well. I can access that constant correctly before any tests run as well.

This is all very confusing.

elasticsearch-bot pushed a commit to logstash-plugins/logstash-input-http_poller that referenced this issue Jun 5, 2017
@headius
Copy link
Member

headius commented Jul 10, 2020

I suspect this is related to concurrency issues in requires or autoloads (which should be fixed by #5764), or else concurrency issues in RSpec similar to rspec/rspec-dev#121.

In any case this issue is rather stale and superseded by others so we'll close it as a dupe.

@headius headius closed this as completed Jul 10, 2020
@headius headius added this to the Invalid or Duplicate milestone Jul 10, 2020
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

No branches or pull requests

2 participants