Thomas Watson created FELIX-5922:
------------------------------------

             Summary: Use of Thread.interrupt() is incorrect for the 
shell.Activator
                 Key: FELIX-5922
                 URL: https://issues.apache.org/jira/browse/FELIX-5922
             Project: Felix
          Issue Type: Bug
          Components: Gogo Shell
    Affects Versions: gogo.shell-1.1.0
            Reporter: Thomas Watson


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:
{quote}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)
{quote}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to