diff --git a/logstash-core/lib/logstash/plugin.rb b/logstash-core/lib/logstash/plugin.rb index a1856eef5..715b28587 100644 --- a/logstash-core/lib/logstash/plugin.rb +++ b/logstash-core/lib/logstash/plugin.rb @@ -121,10 +121,8 @@ class LogStash::Plugin # This is keep for backward compatibility, the logic was moved into the registry class # but some plugins use this method to return a specific instance on lookup # - # - # # Should I remove this now and make sure the pipeline invoke the Registry or I should wait for 6.0 - # Its not really part of the public api but its used by the tests. + # Its not really part of the public api but its used by the tests a lot to mock the plugins. def self.lookup(type, name) LogStash::PluginRegistry.lookup_pipeline_plugin(type, name) end diff --git a/logstash-core/lib/logstash/plugins/registry.rb b/logstash-core/lib/logstash/plugins/registry.rb index 422c494e9..a8ec46a5e 100644 --- a/logstash-core/lib/logstash/plugins/registry.rb +++ b/logstash-core/lib/logstash/plugins/registry.rb @@ -137,7 +137,7 @@ module LogStash module Plugins if plugin.nil? begin path = "logstash/#{type}s/#{plugin_name}" - require path + require path rescue LoadError # Plugin might be already defined in the current scope klass = namespace_lookup(type, plugin_name) plugin = lazy_add(type, plugin_name, klass) rescue => e @@ -170,7 +170,7 @@ module LogStash module Plugins end def lazy_add(type, name, klass) - logger.error("Lazy Adding plugin to the registry", :name => name, :type => type, :class => klass) + logger.error("On demand adding plugin to the registry", :name => name, :type => type, :class => klass) add_plugin(type, name, klass) end diff --git a/logstash-core/spec/api/spec_helper.rb b/logstash-core/spec/api/spec_helper.rb index 8e4912ddf..31ec6f271 100644 --- a/logstash-core/spec/api/spec_helper.rb +++ b/logstash-core/spec/api/spec_helper.rb @@ -5,6 +5,7 @@ require "stud/task" require "logstash/devutils/rspec/spec_helper" $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) require "lib/api/support/resource_dsl_methods" +require_relative "../support/mocks_classes" require 'rspec/expectations' require "logstash/settings" require 'rack/test' diff --git a/logstash-core/spec/support/mocks_classes.rb b/logstash-core/spec/support/mocks_classes.rb index d90318d53..f16d74737 100644 --- a/logstash-core/spec/support/mocks_classes.rb +++ b/logstash-core/spec/support/mocks_classes.rb @@ -2,6 +2,7 @@ require "logstash/outputs/base" require "thread" +module LogStash module Outputs class DummyOutput < LogStash::Outputs::Base config_name "dummyoutput" milestone 2 @@ -47,3 +48,4 @@ class DummyOutputWithEventsArray < LogStash::Outputs::Base def close end end +end end