Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-5922

Use of Thread.interrupt() is incorrect for the shell.Activator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • gogo.shell-1.1.0
    • None
    • Gogo Shell
    • None

    Description

      org.apache.felix.gogo.shell.Activator.StartShellJob.terminate()

      The StartShellJob.terminate() method ends up interrupting the current thread.  It appears that the terminate() method is attempting to terminate the run() method by interrupting the thread executing the StartShellJob task that was submitted to the executor.  The problem is the terminate() method gets called by other threads outside the executor thread running the StartShellJob.  If the intention of the terminate method is to interrupt the executor thread running the StartShellJob then the running thread should be captured in the StartShellJob.run() method and that thread should be interrupted from terminate()

      The way the code is now the thread stopping the gogo.shell bundle ends up being interrupted during Activator.stop(BunleContext) and it remains interrupted upon exit of stop.  This causes other odd behavior if that thread continues to be used to stop other bundles. For example, SCR checks for the interrupted flag:

      The wait for bundle com.ibm.ws.org.apache.felix.gogo.command/70 being started before destruction has been interrupted. Bundle:com.ibm.ws.org.apache.felix.scr(id=13) java.lang.InterruptedException

              at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireNanos(AbstractQueuedSynchronizer.java:1245)

              at java.util.concurrent.locks.ReentrantLock.tryLock(ReentrantLock.java:442)

              at org.apache.felix.scr.impl.Activator$ScrExtension.destroy(Activator.java:280)

              at org.apache.felix.scr.impl.AbstractExtender$1.run(AbstractExtender.java:216)

              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

              at java.util.concurrent.FutureTask.run(FutureTask.java:266)

              at org.apache.felix.scr.impl.AbstractExtender.destroyExtension(AbstractExtender.java:238)

              at org.apache.felix.scr.impl.AbstractExtender.bundleChanged(AbstractExtender.java:132)

      Attachments

        Activity

          People

            Unassigned Unassigned
            tjwatson Tom Watson
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: