diff options
Diffstat (limited to 'activejob')
-rw-r--r-- | activejob/CHANGELOG.md | 12 | ||||
-rw-r--r-- | activejob/lib/active_job/arguments.rb | 18 | ||||
-rw-r--r-- | activejob/lib/active_job/queue_adapter.rb | 10 | ||||
-rw-r--r-- | activejob/test/cases/queue_adapter_test.rb | 13 |
4 files changed, 13 insertions, 40 deletions
diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md index 9bf397af14..5e8d8cb5c9 100644 --- a/activejob/CHANGELOG.md +++ b/activejob/CHANGELOG.md @@ -1,3 +1,11 @@ +* Removed deprecated support to passing the adapter class to `.queue_adapter`. + + *Rafael Mendonça França* + +* Removed deprecated `#original_exception` in `ActiveJob::DeserializationError`. + + *Rafael Mendonça França* + * Added instance variable `@queue` to JobWrapper. This will fix issues in [resque-scheduler](https://github.com/resque/resque-scheduler) `#job_to_hash` method, @@ -16,13 +24,13 @@ class RemoteServiceJob < ActiveJob::Base retry_on CustomAppException # defaults to 3s wait, 5 attempts retry_on AnotherCustomAppException, wait: ->(executions) { executions * 2 } - retry_on ActiveRecord::StatementInvalid, wait: 5.seconds, attempts: 3 + retry_on ActiveRecord::Deadlocked, wait: 5.seconds, attempts: 3 retry_on Net::OpenTimeout, wait: :exponentially_longer, attempts: 10 discard_on ActiveJob::DeserializationError def perform(*args) # Might raise CustomAppException or AnotherCustomAppException for something domain specific - # Might raise ActiveRecord::StatementInvalid when a local db deadlock is detected + # Might raise ActiveRecord::Deadlocked when a local db deadlock is detected # Might raise Net::OpenTimeout when the remote service is down end end diff --git a/activejob/lib/active_job/arguments.rb b/activejob/lib/active_job/arguments.rb index 41ce5f863b..523a0e7f33 100644 --- a/activejob/lib/active_job/arguments.rb +++ b/activejob/lib/active_job/arguments.rb @@ -5,22 +5,10 @@ module ActiveJob # # Wraps the original exception raised as +cause+. class DeserializationError < StandardError - def initialize(e = nil) #:nodoc: - if e - ActiveSupport::Deprecation.warn("Passing #original_exception is deprecated and has no effect. " \ - "Exceptions will automatically capture the original exception.", caller) - end - + def initialize #:nodoc: super("Error while trying to deserialize arguments: #{$!.message}") set_backtrace $!.backtrace end - - # The original exception that was raised during deserialization of job - # arguments. - def original_exception - ActiveSupport::Deprecation.warn("#original_exception is deprecated. Use #cause instead.", caller) - cause - end end # Raised when an unsupported argument type is set as a job argument. We @@ -34,8 +22,8 @@ module ActiveJob module Arguments extend self # :nodoc: - # Calls #uniq since Integer, Fixnum, and Bignum are all the same class on Ruby 2.4+ - TYPE_WHITELIST = [ NilClass, String, Integer, Fixnum, Bignum, Float, BigDecimal, TrueClass, FalseClass ].uniq + TYPE_WHITELIST = [ NilClass, String, Integer, Float, BigDecimal, TrueClass, FalseClass ] + TYPE_WHITELIST.push(Fixnum, Bignum) unless 1.class == Integer # Serializes a set of arguments. Whitelisted types are returned # as-is. Arrays/Hashes are serialized element by element. diff --git a/activejob/lib/active_job/queue_adapter.rb b/activejob/lib/active_job/queue_adapter.rb index 7f9a2da4b0..2e9f1e61be 100644 --- a/activejob/lib/active_job/queue_adapter.rb +++ b/activejob/lib/active_job/queue_adapter.rb @@ -37,12 +37,6 @@ module ActiveJob else if queue_adapter?(name_or_adapter_or_class) name_or_adapter_or_class - elsif queue_adapter_class?(name_or_adapter_or_class) - ActiveSupport::Deprecation.warn "Passing an adapter class is deprecated " \ - "and will be removed in Rails 5.1. Please pass an adapter name " \ - "(.queue_adapter = :#{name_or_adapter_or_class.name.demodulize.remove('Adapter').underscore}) " \ - "or an instance (.queue_adapter = #{name_or_adapter_or_class.name}.new) instead." - name_or_adapter_or_class.new else raise ArgumentError end @@ -54,10 +48,6 @@ module ActiveJob def queue_adapter?(object) QUEUE_ADAPTER_METHODS.all? { |meth| object.respond_to?(meth) } end - - def queue_adapter_class?(object) - object.is_a?(Class) && QUEUE_ADAPTER_METHODS.all? { |meth| object.public_method_defined?(meth) } - end end end end diff --git a/activejob/test/cases/queue_adapter_test.rb b/activejob/test/cases/queue_adapter_test.rb index dc862450aa..f1e0cf78ad 100644 --- a/activejob/test/cases/queue_adapter_test.rb +++ b/activejob/test/cases/queue_adapter_test.rb @@ -20,19 +20,6 @@ class QueueAdapterTest < ActiveJob::TestCase assert_raises(ArgumentError) { ActiveJob::Base.queue_adapter = Mutex.new } end - test "should warn on passing an adapter class" do - klass = Class.new do - def self.name - "fake" - end - - def enqueue(*); end - def enqueue_at(*); end - end - - assert_deprecated { ActiveJob::Base.queue_adapter = klass } - end - test "should allow overriding the queue_adapter at the child class level without affecting the parent or its sibling" do base_queue_adapter = ActiveJob::Base.queue_adapter |