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

Problem with Axiom and ActiveSupport #8

Closed
swistaczek opened this issue Nov 9, 2013 · 6 comments
Closed

Problem with Axiom and ActiveSupport #8

swistaczek opened this issue Nov 9, 2013 · 6 comments

Comments

@swistaczek
Copy link

Hello,
During 'grape' gem integration (rack API framework) and Mongoid I encountered an issue with ActiveSupport and Axiom.
Final stacktrace occurs while calling Class that is including Mongoid::Document.

ArgumentError: comparison of Class with Class failed
    from org/jruby/RubyComparable.java:168:in `<'
    from /Users/ernest.bursa/.rvm/gems/jruby-1.7.6@ayeappz/gems/activesupport-4.0.1/lib/active_support/core_ext/class/subclasses.rb:19:in `descendants'
    from org/jruby/RubyObjectSpace.java:173:in `each_object'
...

I have examined that there is problem with class Axiom::Types::Infinity. That class can not be compared to other classes (done by ActiveSupport in subclasses.rb)

Excerpt from subclasses.rb:

    def descendants # :nodoc:
...
  rescue StandardError # JRuby
    def descendants # :nodoc:
      descendants = []
      ObjectSpace.each_object(Class) do |k|
        descendants.unshift k if k < self # fails here
      end
      descendants.uniq!
      descendants
    end
  end

Are we able to make Axiom::Types::Infinity comparable?

@swistaczek
Copy link
Author

Issue also occurs with:

  • Axiom::Types::NegativeInfinity

@mbj
Copy link
Collaborator

mbj commented Nov 10, 2013

I blame activesupport doing core extensions in an incompatible way, again. Virtus and axiom both dont do core extensions. I'm also sick of workarounding broken core extensions in AS. But I'm not the maintainer of virtus, so I strongly suggest pusing that issue upstream to AS.

@swistaczek
Copy link
Author

Ok, so currently I will 'monkey patch' active_support method with rescue nil inside my project and push that issue to active_support project.

@dkubb
Copy link
Owner

dkubb commented Nov 11, 2013

While active_support does some things that we find questionable, I'm not sure this is one of them. It's expecting that all Class instances support a given interface for #<. It could be argued that since Class#< works one way, all subclass instances should support that interface otherwise they'll be breaking the Liskov Substitution Principle.

I'm going to think about this a bit, and see if there are fixes I can make on my end.

@dkubb dkubb closed this as completed in 3b2e663 Nov 11, 2013
@dkubb
Copy link
Owner

dkubb commented Nov 11, 2013

@swistaczek I just pushed a commit to the repo that I believe should fix this. Can you test it out and let me know if it resolves your issue? If it does I'll release a new axiom-types gem and see if virtus' dep can be bumped too.

@swistaczek
Copy link
Author

Ok, thanks. I will take a look.

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

3 participants