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