Jacob MaineJacob Maine
SF Standup 3/1/2010: JRuby skips ensure blocks when killed
edit Posted by Jacob Maine on Monday March 01, 2010 at 09:18AM

When you kill a JRuby process (e.g. with a SIGINT) you can't bank on ensure blocks being executed. Of course, this is worrisome - file handles and other connections won't be closed. The problem boils down to this example:

$ cat kill_me.rb 
begin
  sleep
ensure
  puts 'executed ensure'
end
$ 
$ ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
$
$ ruby kill_me.rb 
^Cexecuted ensure
kill_me.rb:2:in `sleep': Interrupt
    from kill_me.rb:2
$
$ jruby -v
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_13) [x86_64-java]
$
$ jruby kill_me.rb 
^C$ 

Chris HeisterkampChris Heisterkamp
Standup 08/05/2009: BugMash this weekend
edit Posted by Chris Heisterkamp on Wednesday August 05, 2009 at 09:29AM

Interesting Things

  • RailsBridge is organizing a global BugMash to help knock down some of the bugs on the Rails lighthouse this weekend. If your interested in helping out there is more information on their wiki

  • We started using JRuby for a project and wanted to use JRuby to run our specs. If you install RSpec 1.2.7 or higher you can specify the ruby command used to run your SpecTask in rspec.rake like this:

  desc "Run all specs in spec directory (excluding plugin specs)"
  Spec::Rake::SpecTask.new(:spec) do |t|
    t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/../../spec/spec.opts\""]
    t.spec_files = FileList['spec/**/*/*_spec.rb']
    t.ruby_cmd = 'jruby'
  end

Mike GraftonMike Grafton
New York Standup 11/24/2008
edit Posted by Mike Grafton on Monday November 24, 2008 at 03:05PM

Interesting

  • Rails 2.2.2 is released!

  • Even Rails 2.2.2 isn't always threadsafe. I found this out by running a script with JRuby from the command line. The script loaded the Rails environment and then launched two threads that simply tried to resolve an ActiveRecord class constant. Fireworks (in the form of LoadError) ensued deep inside of const_missing. I'll post the full example later today.

  • Tsearch2 is now built into Postgres (as of 8.3). This means you must remove the metadata from your tables, since Postgres now stores it in a separate place.