Skip to content

Commit

Permalink
🐛 fix shutdown
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Gaikwad <[email protected]>
  • Loading branch information
pranavgaikwad committed Dec 13, 2024
1 parent 5b39d25 commit 15784a0
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,10 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide
}

waitErrorChannel := make(chan error)
wg := &sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
err := cmd.Start()
if err != nil {
cancelFunc()
Expand All @@ -429,10 +432,16 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide
stdout.Close()
}
}()

// This will close the go routine above when wait has completed.
go func() {
waitErrorChannel <- cmd.Wait()
}()

go func() {
wg.Wait()
}()

rpc := jsonrpc2.NewConn(jsonrpc2.NewHeaderStream(stdout, stdin), log)

rpc.AddHandler(jsonrpc2.NewBackoffHandler(log))
Expand Down

0 comments on commit 15784a0

Please sign in to comment.