Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1302

Surefire does not wait long enough for the forked VM and assumes it to be dead

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.19.1
    • 2.20.1
    • Maven Surefire Plugin
    • None

    Description

      This issue happens because surefire kills the forked container if it times out waiting for the 'ping'.

      In org.apache.maven.surefire.booter.ForkedBooter class there is hardcoded constant PING_TIMEOUT_IN_SECONDS = 20 which is used in the following method:

      private static ScheduledFuture<?> listenToShutdownCommands( CommandReader reader )
          {
              reader.addShutdownListener( createExitHandler( reader ) );
              AtomicBoolean pingDone = new AtomicBoolean( true );
              reader.addNoopListener( createPingHandler( pingDone ) );
              return JVM_TERMINATOR.scheduleAtFixedRate( createPingJob( pingDone, reader ),
                                                         0,PING_TIMEOUT_IN_SECONDS, SECONDS );
          }
      

      to create ScheduledFuture.

      In some of the cases the forked container might respond a bit later than it's expected and surefire kills it

      private static Runnable createPingJob( final AtomicBoolean pingDone, final CommandReader reader  )
          {
              return new Runnable()
              {
                  public void run()
                  {
                      boolean hasPing = pingDone.getAndSet( false );
                      if ( !hasPing )
                      {
                          exit( 1, KILL, reader, true );
                      }
                  }
              };
          }
      

      As long as we need to terminate it anyway, It would be really helpful if the problem could be solved making the PING_TIMEOUT_IN_SECONDS configurable with the ability to specify the value from maven-surefire-plugin.

      It would help to configure this timeout based on needs and factors of the projects where surefire runs.

      Attachments

        1. 2017-05-18T05-48-08_685-jvmRun1.dumpstream
          351 kB
          Olivier Peyrusse
        2. surefire-gclog.log
          1.26 MB
          Olivier Peyrusse
        3. surefire-logs
          6 kB
          Olivier Peyrusse
        4. surefire-tests-terminated-master-aa9330316038f6b46316ce36ff40714ffc7cf299.zip
          5 kB
          Yuriy Zaplavnov
        5. tests_log_01.txt
          111 kB
          Yuriy Zaplavnov
        6. tests_log_02.txt
          1 kB
          Yuriy Zaplavnov

        Issue Links

          Activity

            People

              tibordigana Tibor Digana
              xeagle Yuriy Zaplavnov
              Votes:
              4 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: