Skip to content

Commit

Permalink
fix(cluster/operation): java verion maybe in the middle (#1124)
Browse files Browse the repository at this point in the history
Co-authored-by: Ti Chi Robot <71242396+ti-chi-bot@users.noreply.github.com>
  • Loading branch information
jsvisa and ti-chi-bot authored Feb 22, 2021
1 parent 4052b6c commit c3f11c5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/cluster/operation/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,14 +767,17 @@ func CheckJRE(ctx context.Context, e ctxt.Executor, host string, topo *spec.Spec
return
}
if len(stderr) > 0 {
// java -version returns as below:
// openjdk version "1.8.0_265"
// openjdk version "11.0.8" 2020-07-14
line := strings.Split(string(stderr), "\n")[0]
fields := strings.Split(line, " ")
ver := strings.Trim(fields[len(fields)-1], "\"")
if !strings.HasPrefix(ver, "1.8.") {
fields := strings.Split(line, `"`)
ver := strings.TrimSpace(fields[1])
if strings.Compare(ver, "1.8") < 0 {
results = append(results, &CheckResult{
Name: CheckNameCommand,
Err: fmt.Errorf("java version %s is not supported, use Java 8 (1.8)", ver),
Msg: "Installed JRE is not Java 8",
Err: fmt.Errorf("java version %s is not supported, use Java 8 (1.8)+", ver),
Msg: "Installed JRE is not Java 8+",
})
} else {
results = append(results, &CheckResult{
Expand Down

0 comments on commit c3f11c5

Please sign in to comment.