Felix
  1. Felix
  2. FELIX-3703

Race condition in gogo runtime activator

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: gogo.runtime-0.10.0
    • Fix Version/s: gogo.shell-0.12.0
    • Component/s: Gogo Runtime
    • Labels:
      None
    • Environment:
      Embedded felix 4.0.3

      Description

      Starting gogo.command (0.12.0) before gogo.runtime(0.10.0) produces CommandNotFoundException: Command not found: gosh.
      This is because runtime's Activator first registers CommandProcessor before creating commandTracker.
      Creating CommandProcessor triggers event on .command which will start adding commands, but since commandTracker is not present, those commands will be ignored.

      1. osgi-embedded.zip
        4 kB
        Tomas Pan
      2. my.patch
        0.8 kB
        Tomas Pan

        Activity

        Hide
        Derek Baum added a comment -

        fixed by FELIX-3706.

        Show
        Derek Baum added a comment - fixed by FELIX-3706 .
        Hide
        Derek Baum added a comment -

        Hi Thomas,

        Thanks for the stack trace and test case.

        Coincidently, I recently filed FELIX-3706 which fixes this problem.
        (I didn't realise it was the same problem until I saw the stack trace).

        Your test case works if you use gogo-shell-0.11.0-SNAPSHOT, using the subversion HEAD containing the fix for FELIX-3706.

        Show
        Derek Baum added a comment - Hi Thomas, Thanks for the stack trace and test case. Coincidently, I recently filed FELIX-3706 which fixes this problem. (I didn't realise it was the same problem until I saw the stack trace). Your test case works if you use gogo-shell-0.11.0-SNAPSHOT, using the subversion HEAD containing the fix for FELIX-3706 .
        Hide
        Tomas Pan added a comment -

        Hi Derek, perhaps I am doing something wrong during initialization, please find attached test case. When I start runtime after command and shell, I don't see the gogo shell and the "Gogo shell" thread is killed by this exception:
        gogo: CommandNotFoundException: Command not found: gosh
        org.apache.felix.gogo.runtime.CommandNotFoundException: Command not found: gosh
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
        at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
        at java.lang.Thread.run(Thread.java:662)

        Show
        Tomas Pan added a comment - Hi Derek, perhaps I am doing something wrong during initialization, please find attached test case. When I start runtime after command and shell, I don't see the gogo shell and the "Gogo shell" thread is killed by this exception: gogo: CommandNotFoundException: Command not found: gosh org.apache.felix.gogo.runtime.CommandNotFoundException: Command not found: gosh at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474) at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403) at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108) at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183) at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120) at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89) at org.apache.felix.gogo.shell.Activator.run(Activator.java:75) at java.lang.Thread.run(Thread.java:662)
        Hide
        Tomas Pan added a comment -

        test case

        Show
        Tomas Pan added a comment - test case
        Hide
        Derek Baum added a comment -

        Hi Thomas,

        The gogo:gosh command is provided by the Shell bundle, not the Command bundle and is therefore present even if the Command bundle is not started.

        I cannot reproduce the condition you describe, even if I start the Shell bundle before the Runtime bundle.

        A ServiceTracker is used to locate gogo commands in other bundles. It should not matter when this tracker is started, as it gives an initial list of matching services and then updates and new services appear.

        The patch you provided caused a NPE at Activator:156 where the process field is accessed.

        Please provide more details of your problem, ideally a test-case.

        Show
        Derek Baum added a comment - Hi Thomas, The gogo:gosh command is provided by the Shell bundle, not the Command bundle and is therefore present even if the Command bundle is not started. I cannot reproduce the condition you describe, even if I start the Shell bundle before the Runtime bundle. A ServiceTracker is used to locate gogo commands in other bundles. It should not matter when this tracker is started, as it gives an initial list of matching services and then updates and new services appear. The patch you provided caused a NPE at Activator:156 where the process field is accessed. Please provide more details of your problem, ideally a test-case.
        Hide
        Tomas Pan added a comment -

        patch

        Show
        Tomas Pan added a comment - patch

          People

          • Assignee:
            Derek Baum
            Reporter:
            Tomas Pan
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development