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
expect and_call_original messing up with modules build as jruby extensions. #964
Comments
Can you try something for me? Can you run your build with:
|
Hi @JonRowe I tried to run https://github.com/purbon/playground/tree/master/call_origin_with_module with your proposed options and I see the same error:
I did several attempts to reproduce this error with code as the one in 6f1941b, however I was only able to reproduce this in situations as the one using https://github.com/guyboertje/jrjackson, the code checking here, and messing the stuff up is defined in https://github.com/guyboertje/jrjackson/blob/master/src/main/java/com/jrjackson/JrJacksonRaw.java#L27 .... might be we found also an issue in jruby? |
Can reproduce this against my local dev setup. |
This did not work against 2.14.0 |
trying to find bisect commits on master that work for this error. |
green with this combo of gems:
going to try bisecting against the 2-14 branch. |
This is green in master as of 3956221. Going to work out which commit cause the breaking a little later. |
|
the problem is this line of code, where I'm getting:
|
Consider the following example: require "jrjackson"
m = Module.new do
def self.a
end
end
m_singleton_class = (class << m; self; end)
puts "Pure module singleton class owner #{m_singleton_class.instance_method(:a).owner.inspect}"
puts "Pure module singleton class owner equals singleton class? #{m_singleton_class.instance_method(:a).owner == m_singleton_class}"
j = JrJackson::Raw
j_singleton_class = (class << j; self; end)
puts "jrjackson singleton class owner #{j_singleton_class.instance_method(:generate).owner.inspect}"
puts "jrjackson singleton class owner equals singleton class? #{j_singleton_class.instance_method(:generate).owner == j_singleton_class}" output:
So, unless I'm reading this wrong, JRuby has a bug in the return values from the This causes some of our internal method stashing and unstashing logic to behave incorrectly. I'd love a second opinion on this. @JonRowe do you think I've called it correctly? |
I tested a hypothetical fix to this by swapping out the owner in this exact case, I got the following error:
|
I'm increasingly convinced this is a JRuby bug. If someone from @rspec/rspec agrees I think we should reach out to the JRuby team and see if they can help us out? |
Yeah that looks like a bug to me ... is there an analogous case we could provide for MRI to show that there is a behavioural difference? |
@xaviershay the behaviour difference is on a pure module versus a jruby extension one, and the behaviour of the pure module is the same in MRI and JRuby, obviously, we can't run a JRuby extension on MRI. |
@purbon btw, as a work around, you could simply wrap |
@rspec/rspec I'm going to write a minimal reproduction case that creates it's own JRuby module to see if my understanding is correct and then ping the JRuby folks. |
Thanks a lot for your debugging, is much a appreciate it! For now this is not a hard issue for us, but would be nice to have so we can use mocks as "expected". Happy to help rspec reporting issues :-), this is such a great thing for ruby 👍 |
@samphippen your explanation makes sense to me, as is what JRuby is doing when you "fixed" it :) |
I'm not gonna be able to do the JRuby thing for a while because of sudden unexpected busyness but roughly I think the repro case we'd want to build is:
@purbon could you build that for us? If not don't worry. |
@samphippen I can, I will report here when done. |
Hey @purbon did you ever get a chance to build those tests @samphippen was talking about? |
@JonRowe I apologies, not jet! I hope to do by soon, probably by the end of the week. |
sorry, for being really late to this, going to work on this today :P I update this as soon as I get something up and working 😸 |
Hi, Here: http://lists.ruby-lang.org/pipermail/jruby/2015-August/000082.html are more details of my error 😸 Thanks a lot, hope to finally get this up and running! :-P /pere |
@JonRowe @samphippen I finally managed to make happy jruby with the extension, was the name of the service not being the one :P, anyway! now the code in the repo works, but I could not make the test fail using the test case described by @samphippen, is the anything wrong with my implementation? /cheers |
Hi again, I recall one slightly small thing in jrjackson that might be the situation that caused this test to fail, actually is this part of the code:
this is how methods are defined, so not using one name, but also two I guess with the idea of making aliases. Not sure if this is standard way to do it, but I updated the code in [1] and then if you use the module you can make the test to fail. I guess this looks to me like a jruby bug, but not sure about the details there, because to use the singleton class it pass perfect. /cheers |
/cc @samphippen |
I've handed the repro case over to @headius who confirms this is real, see the linked JRuby issue for details. |
This was fixed by jruby/jruby#3463 |
Thanks @headius |
While doing some test to upgrade https://github.com/elastic/logstash to use the last rspec set of gems, I found out an issue with the way expectation with the and_call_orignal call work in the 3.x branch.
Situation
In logstash we're using the jruby wrapper of jrjackson [1] as a json lib, so we get a really fast json processing. So to build the test we use calls like:
during the upgrade to use rspec 3.x I discovered that this kind of expectation were not playing well anymore, as they did with versions < 2.99. There seems to be a regression with using the
and_call_original
in modules defined as jruby/java exceptions.To make a bit more easy to reproduce this I made a simple example that you can find at https://github.com/purbon/playground/tree/master/call_origin_with_module, running the test in this dummy gem will:
if using a version <= 2.99:
[1] https://github.com/guyboertje/jrjackson
The text was updated successfully, but these errors were encountered: