fix geoip external DB shutdown nil exception (#13224) (#13225)

Fixed: #13208
This commit is contained in:
kaisecheng 2021-09-15 15:30:52 +01:00 committed by GitHub
parent 82993fa6f1
commit 050eb98f0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -291,7 +291,7 @@ module LogStash module Filters module Geoip class DatabaseManager
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)

View file

@ -378,5 +378,13 @@ describe LogStash::Filters::Geoip do
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