Skip to content

Commit 1acf1b3

Browse files
committed
Refactor initialization to prevent a resource leak.
Fixes #132 . Fixes #133
1 parent 8b741d7 commit 1acf1b3

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 4.0.2
2+
- Fixed resource leak where this plugin might get double initialized during plugin reload, leaking a thread + some objects
3+
14
## 4.0.1
25
- Fix a potential race
36

lib/logstash/filters/grok.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require "logstash/namespace"
44
require "logstash/environment"
55
require "logstash/patterns/core"
6+
require "grok-pure" # rubygem 'jls-grok'
67
require "set"
78

89
# Parse arbitrary text and structure it.
@@ -246,18 +247,12 @@ class LogStash::Filters::Grok < LogStash::Filters::Base
246247
]
247248

248249
public
249-
def initialize(params)
250-
super(params)
250+
def register
251251
# a cache of capture name handler methods.
252252
@handlers = {}
253253

254254
@timeout_enforcer = TimeoutEnforcer.new(@logger, @timeout_millis * 1000000)
255255
@timeout_enforcer.start! unless @timeout_millis == 0
256-
end
257-
258-
public
259-
def register
260-
require "grok-pure" # rubygem 'jls-grok'
261256

262257
@patternfiles = []
263258

logstash-filter-grok.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-filter-grok'
4-
s.version = '4.0.1'
4+
s.version = '4.0.2'
55
s.licenses = ['Apache License (2.0)']
66
s.summary = "Parses unstructured event data into fields"
77
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"

0 commit comments

Comments
 (0)