Webrick problem - NoMethodError: private method `gsub!' called for #<Class
---------------------------------------------------------------------------
Key: JRUBY-4864
URL: http://jira.codehaus.org/browse/JRUBY-4864
Project: JRuby
Issue Type: Bug
Components: Standard Library
Affects Versions: JRuby 1.5.1
Environment: Ubuntu 10.04
Reporter: Michael Pitman
Assignee: Thomas E Enebo
Issue copied from ruby-forum (http://www.ruby-forum.com/topic/206225). If it
doesn't get fixed in the ruby or rails standard libraries, we may at least be
able to fix it for jruby.
I won't re-paste the problem here, but will re-state the issue. When running
rails (I'm using rails 2.1.2) using webrick in jruby-1.5.1, any content found
to be not modified (i.e. sending back an http result code of 304) is causing a
fatal crash with "NoMethodError: private method `gsub!' called for
#<Class:0x.....>".
The root cause seems to be that the default file handler in
HTTPServlet::DefaultFileHandler is raising a NotModified exception in which the
message is a class, rather than a string (this may now be the behaviour
generally in jruby, but it's causing a problem here). The DispatchServlet in
webrick_server in rails is using that exception to call set_error on the
HTTPResponse. set_error tries to create an error page with the message from the
exception. Because that message is a class, not a string, when it tries to
escape the non-HTML characters using HTMLUtils, HTMUtils.escape is falling over.
There are several ways to patch it. The easiest is in
lib/ruby/1.8/webrick/htmlutils.rb, where we can call to_s on the string input
(and dup if it was already a string), but that may not be the cleanest way to
do it...
An alternative, without patching the rails side of things, would be to change
set_error to escape ex.message.to_s, rather than just ex.message. I think it's
used in two places.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email