Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-10785

failure to terminate logcat reading for android emulator

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Labels:
      None
    • Environment:
      Jenkins 1.426 with Android emulator plugin 1.16-SNAPSHOT.
      Slave/emulator running on Windows 7 with android SDK 11
      Jenkins master running on Ubuntu 10.04.
    • Similar Issues:

      Description

      Whilst investigating occasional failure to shutdown the android emulator processes during a jenkins build (see JENKINS-10639) I noticed that the logcat copier threads were not shutdown from a previous build.

      My slave Thread Dump included the following about 30 minutes after the associated job had completed.

      C:\Android\android-sdk11/platform-tools/adb.exe -s emulator-57045 logcat -v time: stderr copier
      "C:\Android\android-sdk11/platform-tools/adb.exe -s emulator-57045 logcat -v time: stderr copier" Id=1588 Group=main RUNNABLE (in native)
      at java.io.FileInputStream.readBytes(Native Method)
      at java.io.FileInputStream.read(Unknown Source)
      at hudson.util.StreamCopyThread.run(StreamCopyThread.java:60)
      
      C:\Android\android-sdk11/platform-tools/adb.exe -s emulator-57045 logcat -v time: stdout copier
      "C:\Android\android-sdk11/platform-tools/adb.exe -s emulator-57045 logcat -v time: stdout copier" Id=1587 Group=main RUNNABLE (in native)
      at java.io.FileInputStream.readBytes(Native Method)
      at java.io.FileInputStream.read(Unknown Source)
      at java.io.BufferedInputStream.read1(Unknown Source)
      at java.io.BufferedInputStream.read(Unknown Source)
      - locked java.io.BufferedInputStream@17502df
      at java.io.FilterInputStream.read(Unknown Source)
      at hudson.util.StreamCopyThread.run(StreamCopyThread.java:60)
      

      In this case the debug information that I had added to the emulator shutdown told me that the call to "sendEmulatorCommand" failed because the emulator telnet interface did not respond. Hence killed was false and the {{logcatProcess.kill() }} call was never made.

          if (logcatProcess != null) {
              logcatStream.close();
              if (killed && logcatProcess.isAlive()) {
                  // This should have stopped when the emulator was,
                  // but if not attempt to kill the process manually
                  logcatProcess.kill();
              }
      
              // Archive the logs
              if (logcatFile.length() != 0) {
                  log(logger, Messages.ARCHIVING_LOG());
                  logcatFile.copyTo(new FilePath(artifactsDir).child("logcat.txt"));
              }
              logcatFile.delete();
          }
      

      I think that the cleanup routine should always kill the logcat process if it is still alive. Maybe it should give a little grace period where it just polls to give the process a chance to shut down normally.

      I will see if I can find some time to put a patch together.

        Attachments

          Activity

            People

            • Assignee:
              oldelvet Richard Mortimer
              Reporter:
              oldelvet Richard Mortimer
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: