I ran in to this error "NoMethodError (undefined method `controller_name' for nil:NilClass)" when trying to use config.threadsafety!. The patch by the OP works for me. I'm on Rails 2.3.10, but glancing at the code I believe it applies to Rails 3 as well.
-Greg