Skip to content

Commit

Permalink
Fixed issue with race conditions in test further up the stack.
Browse files Browse the repository at this point in the history
  • Loading branch information
daveshanley committed Apr 20, 2024
1 parent b3f6e33 commit 31d929f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions schema_validation/locate_schema_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
func LocateSchemaPropertyNodeByJSONPath(doc *yaml.Node, JSONPath string) *yaml.Node {
var locatedNode *yaml.Node
doneChan := make(chan bool)
locatedNodeChan := make(chan *yaml.Node)
go func() {
defer func() {
if err := recover(); err != nil {
Expand All @@ -30,8 +31,12 @@ func LocateSchemaPropertyNodeByJSONPath(doc *yaml.Node, JSONPath string) *yaml.N
if len(locatedNodes) > 0 {
locatedNode = locatedNodes[0]
}
doneChan <- true
locatedNodeChan <- locatedNode
}()
<-doneChan
return locatedNode
select {
case locatedNode = <-locatedNodeChan:
return locatedNode
case <-doneChan:
return nil
}
}

0 comments on commit 31d929f

Please sign in to comment.