Skip to content

Commit

Permalink
Java agent class path warning printed from Java 11
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanbisutti committed Jan 22, 2025
1 parent 94ce828 commit 582d492
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public void init(EarlyInitAgentConfig earlyConfig) {
// class path null with a Spring Boot executable JAR
if (classPath != null
// JAR name in Maven central, the user could have renamed it
&& isJavaVersionEqualOrGreaterThan11() // -javaagent content added to the classpath in
// Java 1.8
&& classPath.contains("applicationinsights-agent")) {
startupLogger.warn(
"The applicationinsights-agent JAR is in the class path. You should remove it because it could lead to unexpected results. You should configure the Java agent with -javaagent. You can also use the runtime attachment with Spring Boot applications.");
Expand All @@ -151,6 +153,11 @@ public void init(EarlyInitAgentConfig earlyConfig) {
}
}

private static boolean isJavaVersionEqualOrGreaterThan11() {
String javaVersion = System.getProperty("java.vm.specification.version");
return !"1.8".equals(javaVersion) && !"9".equals(javaVersion) && !"10".equals(javaVersion);
}

private static Map<String, String> findEnvVariables() {
Map<String, String> env = System.getenv();
return env.entrySet().stream()
Expand Down

0 comments on commit 582d492

Please sign in to comment.