Skip to content

[SUREFIRE-2114] Surefire is going to kill self fork JVM. The exit has elapsed 30 seconds after System.exit(0). #2797

@jira-importer

Description

@jira-importer

Kamalpreet opened SUREFIRE-2114 and commented

Hi Team, 

I'm using maven surefire plugin (Latest Version) to execute tests on two testing frameworks (e.g, jUnit, jBehave).

Have tried to implement parallelisation by spawning couple of Threads which in turn create processes to execute surefire jar, taking it from -

ManagementFactory.getRuntimeMXBean().getSystemProperties().get("sun.java.command");

Code snippet to show process creation - CustomRunner.java

  void run() {
    ProcessBuilder processBuilder = new ProcessBuilder(commandArray);
    Map<String, String> environment = processBuilder.environment();
    environment.put("platformIndex", String.valueOf(platformIndex));
    try {
        processBuilder.inheritIO();
        Process p = processBuilder.start();
        LOGGER.info("Is Alive {} {}", p.isAlive(), LocalTime.now());
        int statusCode = p.waitFor();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

EntryPoint.java

for (int i = 0; i < 3; i++) {
   Thread thread = new Thread(new CustomRunner(commandArray, String.valueOf(i)));
   thread.start();
   threadList.add(thread);
 }
threadList.forEach(thread -> {
   try {
     thread.join();
   } catch (InterruptedException e) {
     throw new RuntimeException(e);
   }
});
    
System.exit(exitcode);

After running two or sometimes three processes in corresponding Threads, the process execution got stuck on p.waitFor();

Then the process exits after 30 secs and with error message "Surefire is going to kill self fork JVM. The exit has elapsed 30 seconds after System.exit(0)." resulting in Build Failure (sometimes it doesn't) though the tests have passed in their respective processes.

Seems like surefire execution is stuck in some processes. Could you please let me know what can be the possible reasons for it and how to mitigate this? Tried extending the ForkedProcessTimeoutInSeconds to few minutes but no luck.

Any help is much appreciated.


Attachments:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:criticalCrashes, loss of data, severe memory leak

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions