aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2012-05-21 19:02:48 -0700
committerMichael Koziarski <michael@koziarski.com>2012-05-21 19:02:48 -0700
commite44009aa2bca8fc8f57c432d10e74aff84bbae29 (patch)
tree8bf5d322000778e4d34de42c66077c2eb3ecf46c /activesupport
parentedb87b19d42b2a47708a78e0762a9e761aaf1277 (diff)
parentb52c66f1bedb6ed5a08c106a199a53f67c9f6ec2 (diff)
downloadrails-e44009aa2bca8fc8f57c432d10e74aff84bbae29.tar.gz
rails-e44009aa2bca8fc8f57c432d10e74aff84bbae29.tar.bz2
rails-e44009aa2bca8fc8f57c432d10e74aff84bbae29.zip
Merge pull request #5125 from winston/log_exception_when_cache_read_fails
#read_entry in ActiveSupport::Cache::FileStore should log details of the exception when an exception is thrown
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/cache/file_store.rb3
-rw-r--r--activesupport/test/caching_test.rb9
2 files changed, 11 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb
index 89bdb741d0..5be63af342 100644
--- a/activesupport/lib/active_support/cache/file_store.rb
+++ b/activesupport/lib/active_support/cache/file_store.rb
@@ -81,7 +81,8 @@ module ActiveSupport
if File.exist?(file_name)
File.open(file_name) { |f| Marshal.load(f) }
end
- rescue
+ rescue => e
+ logger.error("FileStoreError (#{e}): #{e.message}") if logger
nil
end
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index d62b782e2d..a75db47be8 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -553,6 +553,9 @@ class FileStoreTest < ActiveSupport::TestCase
@cache = ActiveSupport::Cache.lookup_store(:file_store, cache_dir, :expires_in => 60)
@peek = ActiveSupport::Cache.lookup_store(:file_store, cache_dir, :expires_in => 60)
@cache_with_pathname = ActiveSupport::Cache.lookup_store(:file_store, Pathname.new(cache_dir), :expires_in => 60)
+
+ @buffer = StringIO.new
+ @cache.logger = ActiveSupport::Logger.new(@buffer)
end
def teardown
@@ -612,6 +615,12 @@ class FileStoreTest < ActiveSupport::TestCase
ActiveSupport::Cache::FileStore.new('/test/cache/directory').delete_matched(/does_not_exist/)
end
end
+
+ def test_log_exception_when_cache_read_fails
+ File.expects(:exist?).raises(StandardError, "failed")
+ @cache.send(:read_entry, "winston", {})
+ assert_present @buffer.string
+ end
end
class MemoryStoreTest < ActiveSupport::TestCase