Skip to content

Instantly share code, notes, and snippets.

View nicksieger's full-sized avatar

Nick Sieger nicksieger

View GitHub Profile
diff --git a/src/org/jruby/javasupport/JavaUtil.java b/src/org/jruby/javasupport/JavaUtil.java
index e8de4c4..eb0842e 100644
--- a/src/org/jruby/javasupport/JavaUtil.java
+++ b/src/org/jruby/javasupport/JavaUtil.java
@@ -868,6 +868,8 @@ public class JavaUtil {
public static Object convertArgumentToType(ThreadContext context, IRubyObject arg, Class target) {
if (arg instanceof JavaObject) {
return coerceJavaObjectToType(context, ((JavaObject)arg).getValue(), target);
+ } else if (arg.respondsTo("java_object")) {
+ return convertArgumentToType(context, arg.callMethod(context, "java_object"), target);
diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb
index bdae5f9..a6bac65 100644
--- a/actionpack/lib/action_controller/dispatcher.rb
+++ b/actionpack/lib/action_controller/dispatcher.rb
@@ -20,8 +20,10 @@ module ActionController
end
if defined?(ActiveRecord)
- before_dispatch { ActiveRecord::Base.verify_active_connections! }
to_prepare(:activerecord_instantiate_observers) { ActiveRecord::Base.instantiate_observers }
Database connections are now pooled, one pool per #establish_connection call.
Pools start out empty and grow as necessary to a maximum size (default is 5,
configure size with key 'pool' in your database configuration). If no
connections are available, a thread will wait up to a 'wait_timeout' time
(default is 5 seconds).
Connections are verified and reset when checked out from the pool (usually
upon first access to ActiveRecord::Base.connection), and returned back to the
pool after each request.
require File.dirname(__FILE__) + '/bench_model'
puts "Widget.find(:all)"
Benchmark.bm do |make|
TIMES.times do
make.report do
10_000.times do
Widget.find(:all)
end
end
java.lang.StackOverflowError
at org.jruby.java.proxies.JavaInterfaceTemplate.appendFeaturesToClass(JavaInterfaceTemplate.java:85)
at org.jruby.java.proxies.JavaInterfaceTemplate.append_features(JavaInterfaceTemplate.java:73)
at org.jruby.java.proxies.JavaInterfaceTemplate$s_method_1_0$RUBYFRAMEDINVOKER$append_features.call(org/jruby/java/proxies/JavaInterfaceTemplate$s_method_1_0$RUBYFRAMEDINVOKER$append_features.gen)
at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneBlock.call(JavaMethod.java:580)
at org.jruby.RubyClass.invoke(RubyClass.java:333)
...
at org.jruby.javasupport.util.RuntimeHelpers.invokeAs(RuntimeHelpers.java:366)
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index 838b043..c7f04de 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -201,7 +201,7 @@ module ActiveRecord
def checkout_and_verify(c)
c.run_callbacks :checkout
- c.verify!(verification_timeout)
+ c.verify_now!
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index 838b043..5806dea 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -35,7 +35,6 @@ module ActiveRecord
# * +wait_timeout+: number of seconds to block and wait for a connection
# before giving up and raising a timeout error (default 5 seconds).
class ConnectionPool
- delegate :verification_timeout, :to => "::ActiveRecord::Base"
attr_reader :spec
From 662a9ed4286e1cf3118ad333955e16ab761cd350 Mon Sep 17 00:00:00 2001
From: Nick Sieger <[email protected]>
Date: Thu, 4 Sep 2008 14:03:19 +0200
Subject: [PATCH] Deprecate verification_timeout and verify before reset
---
.../abstract/connection_pool.rb | 6 ++----
.../abstract/connection_specification.rb | 15 ++++++++++-----
.../connection_adapters/abstract_adapter.rb | 12 ++++--------
activerecord/test/cases/base_test.rb | 2 +-
From 668d43b053f5f651b66357b3599e4bdec2c4a9e3 Mon Sep 17 00:00:00 2001
From: Nick Sieger <[email protected]>
Date: Thu, 4 Sep 2008 15:16:29 +0200
Subject: [PATCH] Default connection allow_concurrency to false (for PostgreSQL)
---
.../abstract/connection_pool.rb | 3 +--
activerecord/lib/active_record/test_case.rb | 15 +++++++++++++++
activerecord/test/cases/locking_test.rb | 2 ++
activerecord/test/cases/transactions_test.rb | 2 ++
From c5d18f6308d6980238caee2aea97df7894de4533 Mon Sep 17 00:00:00 2001
From: Nick Sieger <[email protected]>
Date: Thu, 4 Sep 2008 15:35:55 +0200
Subject: [PATCH] Remove flawed execute("ROLLBACK") approach; #reset! defaults to nothing
Will need community help to fill out what #reset! should do for each adapter
---
.../connection_adapters/abstract_adapter.rb | 4 +---
.../connection_adapters/mysql_adapter.rb | 2 --
2 files changed, 1 insertions(+), 5 deletions(-)