Skip to content

Commit 6035624

Browse files
committed
Fixed issue with race conditions in test further up the stack.
1 parent 016b8cd commit 6035624

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

schema_validation/locate_schema_property.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
func LocateSchemaPropertyNodeByJSONPath(doc *yaml.Node, JSONPath string) *yaml.Node {
1515
var locatedNode *yaml.Node
1616
doneChan := make(chan bool)
17+
locatedNodeChan := make(chan *yaml.Node)
1718
go func() {
1819
defer func() {
1920
if err := recover(); err != nil {
@@ -30,8 +31,12 @@ func LocateSchemaPropertyNodeByJSONPath(doc *yaml.Node, JSONPath string) *yaml.N
3031
if len(locatedNodes) > 0 {
3132
locatedNode = locatedNodes[0]
3233
}
33-
doneChan <- true
34+
locatedNodeChan <- locatedNode
3435
}()
35-
<-doneChan
36-
return locatedNode
36+
select {
37+
case locatedNode = <-locatedNodeChan:
38+
return locatedNode
39+
case <-doneChan:
40+
return nil
41+
}
3742
}

0 commit comments

Comments
 (0)