Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-6305

ProjectManager.find() return null for project dir - race between Git and Projects




      I was trying to write some gradle projects tests using NbModuleSuite – the plan was to create a simpel gradle project (just buildscript), then open it as a project and inspect.

      To my surprise, calls like FileObject.createAndOpen or FileObject.getOuputStream() write (inside FS Atomic Action) resulted in the project directory not being recognized at all ! When I tried to debug the situation, a stop in the debugger (just a single thread) caused the project to be found magically.

      It turned to be a race between Git module (the workdir is created inside the source tree managed by git) and the Project system: Git module runs as extension to filesystems even inside FS Atomic Action (shown on a pictured stacktrace from debugger) and executes FileOwnerQuery.findOwner on the to-be-project directory before the buildscript is even created. The result of not being a project is then cached - and the cache is reset asynchronously when/after the project file is created.

      But the test manages to call ProjectManager.findProject sooner, while the cache still holds the negative result.

      One of the screenshots shows a debugger that stopped in a situation when the script file has been already created (a message in the output window), but project manager call invoked after the creation does not find a project. Uncommenting the m.invoke() line in HACK section will fix the situation - caches must be reset.

      The other screenshot is a debugger stopping when the to-be-project directory is first inspected, showing that the directory's  is yet empty.

      // cc: entlicher 


        1. git-project-race1.png
          1.06 MB
          Svatopluk Dedic
        2. git-project-race2.png
          1.10 MB
          Svatopluk Dedic
        3. git-project-race-strack.png
          47 kB
          Svatopluk Dedic



            jtulach Jaroslav Tulach
            sdedic Svatopluk Dedic
            0 Vote for this issue
            2 Start watching this issue