From 0401f9cad4fe62f63b23760eccea8239f71efa87 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 1 Oct 2021 11:07:36 -0700 Subject: [PATCH] Check super method to be called and force no arguments if none expected This fixes an issue with Ruby 2.6 where `super` usage when no arguments are passed results in an argument error --- plugins/commands/serve/util/has_broker.rb | 7 ++++++- plugins/commands/serve/util/has_logger.rb | 7 ++++++- plugins/commands/serve/util/has_mapper.rb | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/plugins/commands/serve/util/has_broker.rb b/plugins/commands/serve/util/has_broker.rb index 42122376e..402f17c53 100644 --- a/plugins/commands/serve/util/has_broker.rb +++ b/plugins/commands/serve/util/has_broker.rb @@ -12,7 +12,12 @@ module VagrantPlugins @broker = opts.delete(:broker) raise ArgumentError, "Expected `Broker' to be provided" if @broker.nil? - super + + if self.method(:initialize).super_method.parameters.empty? + super() + else + super + end end end end diff --git a/plugins/commands/serve/util/has_logger.rb b/plugins/commands/serve/util/has_logger.rb index decd36eae..1b096e3b4 100644 --- a/plugins/commands/serve/util/has_logger.rb +++ b/plugins/commands/serve/util/has_logger.rb @@ -10,7 +10,12 @@ module VagrantPlugins def initialize(*args, **opts, &block) @logger = Log4r::Logger.new(self.class.name.downcase) - super + + if self.method(:initialize).super_method.parameters.empty? + super() + else + super + end end end end diff --git a/plugins/commands/serve/util/has_mapper.rb b/plugins/commands/serve/util/has_mapper.rb index 49decc5ee..84e3b87b0 100644 --- a/plugins/commands/serve/util/has_mapper.rb +++ b/plugins/commands/serve/util/has_mapper.rb @@ -14,7 +14,12 @@ module VagrantPlugins if respond_to?(:broker) @mapper.add_argument(broker) end - super + + if self.method(:initialize).super_method.parameters.empty? + super() + else + super + end end end end