Skip to content
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 @@ -469,12 +469,13 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide
// language server has not started - don't error yet
if err != nil && cmd.ProcessState == nil {
log.Info("retrying language server start")
} else {
log.Error(err, "language server stopped with error")
} else if err != nil {
log.Error(err, "language server process terminated")
}
log.V(5).Info("language server stopped")
log.Info("language server stopped")

case <-ctx.Done():
log.Info("language server context cancelled closing pipes")
log.Info("language server context cancelled, closing pipes")
stdin.Close()
stdout.Close()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"runtime"
"strings"
"sync"
"syscall"
"time"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -271,10 +272,15 @@ func (p *javaServiceClient) Stop() {
if err != nil {
p.log.Error(err, "failed to gracefully shutdown java provider")
}
p.cancelFunc()
err = p.cmd.Wait()
if err != nil {
p.log.Info("stopping java provider", "error", err)
if isSafeErr(err) {
p.log.Info("java provider stopped")
} else {
p.log.Error(err, "java provider stopped with error")
}
} else {
p.log.Info("java provider stopped")
}

if len(p.cleanExplodedBins) > 0 {
Expand Down Expand Up @@ -316,6 +322,22 @@ func (p *javaServiceClient) shutdown() error {
return nil
}

func isSafeErr(err error) bool {
if errors.Is(err, context.Canceled) {
return true
}
var exitError *exec.ExitError
if errors.As(err, &exitError) {
if status, ok := exitError.Sys().(syscall.WaitStatus); ok {
if status.Signaled() && (status.Signal() == syscall.SIGTERM || status.Signal() == syscall.SIGKILL) {
return true
}
}
}

return false
}

func (p *javaServiceClient) initialization(ctx context.Context) {
absLocation, err := filepath.Abs(p.config.Location)
if err != nil {
Expand Down
Loading