Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

undefined method `render_partial_with_logging' for class `#<Class:0x617ead84>' org/jruby/RubyModule.java:2256:in `alias_method' #214

Closed
atambo opened this Issue · 15 comments

7 participants

@atambo

I'm getting:

undefined method `render_partial_with_logging' for class `#<Class:0x617ead84>'  org/jruby/RubyModule.java:2256:in `alias_method'

The backtrace:

https://gist.github.com/1962058

Running jruby 1.6.7 with rails 3.2.2 and kaminari 0.13.0

@atambo

The #to_s method on Paginator aliases a method and then undefs the method it aliased which is not threadsafe. I am hitting the above exception when running kaminari in a threaded environment (jruby on rails application with config.threadsafe! uncommented in environment/production.rb). So one pagination request can come in and undef the render_partial_with_logging method while another request is about to alias the render_partial_with_logging method and then explode with the exception in the gist above.

https://github.com/amatsuda/kaminari/blob/master/lib/kaminari/helpers/paginator.rb#L75

@jhund

I keep getting this exception as well. Running jruby 1.6.7 with Rails 3.0.9 in multi threaded mode.

@atambo

@jhund, I ended up switching to https://github.com/mislav/will_paginate as that is threadsafe and has basically the same api.

@jhund

Thanks @atambo, will give that a try.

@bwalsh

Is this still an issue? Thinking about using it in rails 3.2 + jruby 1.6.7

@atambo

Yes this is still an issue. I suggest using https://github.com/mislav/will_paginate in a multi-threaded environment.

@bwalsh

Hmm. To bad. Any thought about this patch ?

see #164

@plentz

same problem here. rails 3.2.8 + jruby 1.6.8 + multithread. related #164

@gregoriokusowski

Is there any problem to leave the render_partial_with_logging method on the subscriber, making it no more temporary?

Something like this:

      def to_s #:nodoc:
        subscriber = ActionView::LogSubscriber.log_subscribers.detect {|ls| ls.is_a? ActionView::LogSubscriber}
        return super @window_options.merge(@options).merge :paginator => self unless subscriber

        # dirty hack to suppress logging render_partial
        class << subscriber
          alias_method :render_partial_with_logging, :render_partial unless defined?(:render_partial_with_logging)
          # do nothing
          def render_partial(event); end
        end

        ret = super @window_options.merge(@options).merge :paginator => self

        class << subscriber
          alias_method :render_partial, :render_partial_with_logging
        end
        ret
      end

It stills not being thread safe, and may miss something, but it will not cause any crash.

@yuki24
Collaborator

I believe this issue solved by #374. Thanks!

@yuki24 yuki24 closed this
@fjyaniez

I'm still having this issue using Rails 3.2.15 and jRuby 1.7.6.

Undefined method render_partial_with_logging for class '#<Class:0x76d7f01>' 
kaminari (0.14.1) lib/kaminari/helpers/paginator.rb:90:in `to_s' 
@gregoriokusowski

@fjyaniez can you check this on 0.15.0?

@fjyaniez

@gregoriokusowski I'll upgrade and try. Any method to force the error to appear?

@gregoriokusowski

Since the error happens when running a multi-threaded environment, it's kinda hard to force it.
You can use a tool like Apache Benchmark/etc to make a lot of parallel requests, but we can't assure that it will happen.

@fjyaniez

Ok I'll just update, do some tests and post here if the error happens again. Thanks!

@RobinDaugherty RobinDaugherty referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.