Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 CP # 746 - Adding ability for provider and service client to shutdown grac… #748

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide
return nil, additionalBuiltinConfig, err
}

waitErrorChannel := make(chan error)
go func() {
err := cmd.Start()
if err != nil {
Expand All @@ -378,6 +379,23 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide
log.Error(err, "unable to start lsp command")
return
}
// Here we need to wait for the command to finish or if the ctx is cancelled,
// To close the pipes.
select {
case err := <-waitErrorChannel:
if err != nil {
log.Error(err, "language server stopped with error")
}
log.V(5).Info("language server stopped")
case <-ctx.Done():
log.Info("language server context cancelled closing pipes")
stdin.Close()
stdout.Close()
}
}()
// This will close the go routine above when wait has completed.
go func() {
waitErrorChannel <- cmd.Wait()
}()
rpc := jsonrpc2.NewConn(jsonrpc2.NewHeaderStream(stdout, stdin), log)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ func (p *javaServiceClient) GetAllReferences(ctx context.Context, symbol protoco

func (p *javaServiceClient) Stop() {
p.cancelFunc()
p.cmd.Wait()
err := p.cmd.Wait()
if err != nil {
p.log.Info("stopping java provider", "error", err)
}
}

func (p *javaServiceClient) initialization(ctx context.Context) {
Expand Down
Loading