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

fix(cluster/operation): extract the correct java's version field #1124

Merged
merged 2 commits into from
Feb 22, 2021
Merged
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
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