Skip to content

Commit

Permalink
JS-70 More descriptive log when extracting node fails (#4834)
Browse files Browse the repository at this point in the history
  • Loading branch information
zglicz authored Sep 20, 2024
1 parent f2b3bf9 commit ebce909
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,15 @@ public void deploy() throws IOException {
LOG.debug("Deployed node version {}", detected);
isAvailable = true;
} catch (Exception e) {
LOG.warn("Embedded Node.js failed to deploy. Will fallback to host Node.js.", e);
LOG.warn("""
Embedded Node.js failed to deploy in {}.
You can change the location by setting the option `sonar.userHome` or the environment variable `SONAR_USER_HOME`.
Otherwise, it will default to {}.
Will fallback to host Node.js.""",
Environment.defaultSonarUserHome(),
deployLocation,
e
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@ public Path getSonarUserHome() {
.of(
configuration.get("sonar.userHome").orElse(null),
System.getenv("SONAR_USER_HOME"),
System.getProperty("user.home") + File.separator + ".sonar"
defaultSonarUserHome()
)
.filter(Objects::nonNull)
.findFirst()
.map(Path::of)
.get();
}

public static String defaultSonarUserHome() {
return System.getProperty("user.home") + File.separator + ".sonar";
}

public String getOsName() {
return System.getProperty("os.name");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ void should_fail_gracefully() throws Exception {
en.deploy();
assertThat(logTester.logs())
.anyMatch(l ->
l.startsWith("Embedded Node.js failed to deploy. Will fallback to host Node.js")
l.startsWith("Embedded Node.js failed to deploy in ") &&
l.contains("You can change the location by setting the option `sonar.userHome` or the environment variable `SONAR_USER_HOME`.") &&
l.endsWith("Will fallback to host Node.js.")
);
}

Expand Down

0 comments on commit ebce909

Please sign in to comment.