diff --git a/x-pack/lib/filters/geoip/database_manager.rb b/x-pack/lib/filters/geoip/database_manager.rb index 94e49365cae..ca63fde9be3 100644 --- a/x-pack/lib/filters/geoip/database_manager.rb +++ b/x-pack/lib/filters/geoip/database_manager.rb @@ -291,7 +291,7 @@ def subscribe_database_path(database_type, database_path, geoip_plugin) end def unsubscribe_database_path(database_type, geoip_plugin) - @states[database_type].plugins.delete(geoip_plugin) if geoip_plugin + @states[database_type].plugins.delete(geoip_plugin) if geoip_plugin && @states end def database_path(database_type) diff --git a/x-pack/spec/filters/geoip/database_manager_spec.rb b/x-pack/spec/filters/geoip/database_manager_spec.rb index bdb13bf78f4..e07cc3df53e 100644 --- a/x-pack/spec/filters/geoip/database_manager_spec.rb +++ b/x-pack/spec/filters/geoip/database_manager_spec.rb @@ -378,5 +378,13 @@ def expect_healthy_database_metric(c) end end + context "shutdown" do + let(:db_manager) { manager = Class.new(LogStash::Filters::Geoip::DatabaseManager).instance } + + it "should unsubscribe gracefully" do + db_manager.subscribe_database_path(CITY, default_city_db_path, mock_geoip_plugin) + expect { db_manager.unsubscribe_database_path(CITY, mock_geoip_plugin) }.not_to raise_error + end + end end end \ No newline at end of file