-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
JRuby 9k doesn't call a rack method in Lotus::Controller tests but MRI yes #3004
Comments
For some reason, I looked at this one briefly a couple days ago. I think it has something to do with the way the weighting is being applied. |
At least what I tried it seems the code in I used the following most stupid way (I'm in cloned Lotus::Controller project)
Result: Ruby 2.2.2
JRuby 9k head
No |
I believe this one is a simple difference in how JRuby and MRI sort the list of mime types and weights. After the above "accept" string is processed, we end up with the following array of mime types and weights (or qualities...both terms are used in the source): [["text/html", 1.0], ["application/xhtml+xml", 1.0], ["application/xml", 0.9]] MRI and JRuby sort this list differently:
Because the weights of "html" and "xhtml" are equal, these are both valid sort results. The actual sort_by is this: values.sort_by do |match, quality|
(match.split('/', 2).count('*') * -10) + quality
end Because neither of these mime types has a "*" as part of its path, they both end up with the same weight for sorting. It seems to me that that either the implementation or the test are depending on sort_by to have the same order on all implementations when elements are equal. I don't think that's a reasonable assumption. The fact that get is not called is probably not related, but it is peculiar and I'll look into that as well. |
FWIW, I did |
Also interesting, someone appears to have attempted to patch around the difference in sort algorithm. This is the full
Note the |
OK. I was looking on a bad place. I'll take a look at your findings and fix later today. Thanks! And what the another issue: not triggering code in the get rack method? It is a bug or not? :) |
@deepj See #3004 (comment) where I mentioned that I did modify MockRequest in my local copy of Rack, and confirmed that it does get called. |
Interesting, I can't confirmed it. In my case it doesn't get called. |
Make sure you're opening the correct copy of Rack; I assume you're testing on JRuby as well as other Ruby impls that would have their own gems. I commented here to close the loop, and I'm going to close this bug now. Let me know if you need anything further :-) |
OK. I'm shamed. You're completely right. My bad :) |
https://github.com/lotus/controller
OK. This is another weird issue for me. I'm not sure how to describe it.
The problem probably lies in calling
get
rack method.Due to this some tests fail on wrong mime type detection under JRuby 9k.
This is a minimal case how to reproduce it:
The text was updated successfully, but these errors were encountered: