elastic / elastic/logstash

Follow-up on the recent environment.rb and require "logstash/util" failure.

Open
#8,109 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
14.9k
Forks
3.5k
Avg merge
1d 4h
Merged PRs (30d)
88

Description

environment.rb is required very early by runner.rb.
runner.rb requires `logstash/namespace` very early - so the module hierarchy is established.

Some files in the Util namespace, do require `logstash/util`, not to actually use any features from the Util module but more for legacy reasons to establish the `LogStash::Util` hierarchy which has already been established via the `require logstash/namespace` call done in runner.rb and in the file itself. The call to `require "logstash/util"` is redundant and dangerous because it then parses the Util module which has dependencies on the Environment having been setup.

What all the above means is, if you want to use a (flawed) Utils namespaced class before LogStash::Environment is fully set up - bad things happen.

The solution is to change all class definitions of the form `class LogStash::Util::SomeClass` to `module LogStash module Util class SomeClass` in the util folder and remove the `require "logstash/util"`

Contributor guide

Open the contributing guide

Research direction

Start by reading runner.rb and environment.rb to understand the early namespace setup, then inspect the class definitions and require "logstash/util" calls in the util folder. Done means the util classes establish their namespace without the redundant require and no longer depend on Environment being initialized merely to define the hierarchy.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.