Skip to content

Commit

Permalink
discovery: Explicitly close opened files (#28859)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitkyrka committed Aug 28, 2024
1 parent e99ce1d commit 5d954e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/collector/corechecks/servicediscovery/usm/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (n nodeDetector) maybeExtractServiceName(filename string) (string, bool) {
if err != nil {
return "", false
}
defer file.Close()
ok, err := canSafelyParse(file)
if err != nil {
//file not accessible or don't exist. Continuing searching up
Expand Down
1 change: 1 addition & 0 deletions pkg/collector/corechecks/servicediscovery/usm/tomcat.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func (te tomcatExtractor) parseServerXML(domainHome string) *tomcatServerXML {
log.Debugf("Unable to locate tomcat server.xml (%q). Err: %v", xmlFilePath, err)
return nil
}
defer file.Close()
var serverXML tomcatServerXML
err = xml.NewDecoder(file).Decode(&serverXML)
if err != nil {
Expand Down

0 comments on commit 5d954e9

Please sign in to comment.