Skip to content

Commit

Permalink
fix geoip external DB shutdown nil exception (#13224) (#13226)
Browse files Browse the repository at this point in the history
Fixed: #13208
  • Loading branch information
kaisecheng authored Sep 15, 2021
1 parent 51835b2 commit fd0927b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion x-pack/lib/filters/geoip/database_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions x-pack/spec/filters/geoip/database_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fd0927b

Please sign in to comment.