2809: Fix disappearing ArvadosApiClient in development mode. refs #2809
authorTom Clegg <tom@curoverse.com>
Fri, 16 May 2014 00:44:28 +0000 (20:44 -0400)
committerTom Clegg <tom@curoverse.com>
Fri, 16 May 2014 00:44:28 +0000 (20:44 -0400)
apps/workbench/app/models/arvados_api_client.rb

index 25e776a94267fd41394d47a4553bc8e03ecd80dd..a7ae8ba3aac5c230a48dc79f92072ae5d645ef0e 100644 (file)
@@ -13,7 +13,14 @@ class ArvadosApiClient
   # An API client object suitable for handling API requests on behalf
   # of the current thread.
   def self.new_or_current
-    Thread.current[:arvados_api_client] ||= new
+    # If this thread doesn't have an API client yet, *or* this model
+    # has been reloaded since the existing client was created, create
+    # a new client. Otherwise, keep using the latest client created in
+    # the current thread.
+    unless Thread.current[:arvados_api_client].andand.class == self
+      Thread.current[:arvados_api_client] = new
+    end
+    Thread.current[:arvados_api_client]
   end
 
   def initialize *args