@@ -284,31 +284,43 @@ static int parseJavaMajorVersion(String version) {
284
284
}
285
285
286
286
static boolean shouldAbortDueToOtherJavaAgents () {
287
- // Simply considering having multiple agents
288
- if (getConfig (LIB_INJECTION_ENABLED_FLAG )
289
- && !getConfig (LIB_INJECTION_FORCE_FLAG )
290
- && getAgentFilesFromVMArguments ().size () > 1 ) {
291
- // Formatting agent file list, Java 7 style
292
- StringBuilder agentFiles = new StringBuilder ();
293
- boolean first = true ;
287
+ // We don't abort if either
288
+ // * We are not using SSI
289
+ // * Injection is forced
290
+ // * There is only one agent
291
+ if (!getConfig (LIB_INJECTION_ENABLED_FLAG ) || getConfig (LIB_INJECTION_FORCE_FLAG ) || getAgentFilesFromVMArguments ().size () <= 1 ) {
292
+ return false ;
293
+ }
294
+
295
+ // If there are 2 agents and one of them is for patching log4j, it's fine
296
+ if (getAgentFilesFromVMArguments ().size () == 2 ) {
294
297
for (File agentFile : getAgentFilesFromVMArguments ()) {
295
- if (first ) {
296
- first = false ;
297
- } else {
298
- agentFiles .append (", " );
298
+ if (agentFile .getName ().toLowerCase .contains ("log4j" )) {
299
+ return false ;
299
300
}
300
- agentFiles .append ('"' );
301
- agentFiles .append (agentFile .getAbsolutePath ());
302
- agentFiles .append ('"' );
303
301
}
304
- System .err .println (
305
- "Info: multiple JVM agents detected, found "
306
- + agentFiles
307
- + ". Loading multiple APM/Tracing agent is not a recommended or supported configuration."
308
- + "Please set the DD_INJECT_FORCE configuration to TRUE to load Datadog APM/Tracing agent." );
309
- return true ;
310
302
}
311
- return false ;
303
+
304
+ // Simply considering having multiple agents
305
+ // Formatting agent file list, Java 7 style
306
+ StringBuilder agentFiles = new StringBuilder ();
307
+ boolean first = true ;
308
+ for (File agentFile : getAgentFilesFromVMArguments ()) {
309
+ if (first ) {
310
+ first = false ;
311
+ } else {
312
+ agentFiles .append (", " );
313
+ }
314
+ agentFiles .append ('"' );
315
+ agentFiles .append (agentFile .getAbsolutePath ());
316
+ agentFiles .append ('"' );
317
+ }
318
+ System .err .println (
319
+ "Info: multiple JVM agents detected, found "
320
+ + agentFiles
321
+ + ". Loading multiple APM/Tracing agent is not a recommended or supported configuration."
322
+ + "Please set the DD_INJECT_FORCE configuration to TRUE to load Datadog APM/Tracing agent." );
323
+ return true ;
312
324
}
313
325
314
326
public static void main (final String [] args ) {
0 commit comments