title: Java 7 Directory WatchService does not detect new files
body: <p>I have implemented a WatchService to listen to a single folder on a Linux (Redhat6) filesystem.
  When I drag/drop a file to the folder (via WinSCP) the file is detected and processed. However, when an FTP process drops files in the folder. They are not picked up??</p>
  
  <p>This is the Thread code</p>
  
  <pre><code>@Override
  public void run() {
  
      log.info("Starting " + NAME);
  
      while (mustLive) {
  
          try {
  
              // get Event or wait for one
              WatchKey watchKey = watchService.take();
              // log.debug("Event found");
  
              // we are only interested in Create Events
              List&lt;WatchEvent&lt;?&gt;&gt; events = watchKey.pollEvents();
  
              for (WatchEvent&lt;?&gt; event : events) {
  
                  // we need to get the Absolute Path, so more code is needed
                  // to retrieve it.
                  Path dir = (Path) watchKey.watchable();
                  Path fullPath = dir.resolve((Path) event.context());
  
                  if (event.kind() == StandardWatchEventKinds.ENTRY_CREATE) {
  
                      log.debug("Created: " + event.context().toString());
                      // callback to process the file
                      caller.processNotificationFile(fullPath, eps);
                  }
  
                  if (event.kind() == StandardWatchEventKinds.ENTRY_DELETE) {
                      // log.debug("Delete: " + event.context().toString());
                  }
                  if (event.kind() == StandardWatchEventKinds.ENTRY_MODIFY) {
                      // log.debug("Modify: " + event.context().toString());
                  }
              }
  
              // reset the Watcher for new
              boolean resetOK = watchKey.reset();
  
              if (!resetOK) {
                  log.debug("Reset NOK");
                  continue;
              }
          } catch (InterruptedException e) {
              killThread();
          }
  
      }
  
  }
  </code></pre>
  
  <p>When I delete and drop the same file (that should have been picked up)in the monitored folder it is detected and picked up (so the Watcher is working and up and running). 
  So somewhere during the FTP copy something goes wrong. Now the only difference is that the file is FTP-ed to the folder as root, but READ access is ON for all files. When I SCP the file I am another user (the same user that owns the WatcherThread).</p>
  
  <p>Is this the problem, that files owned by another user are not picked up? And if so, how to fix this?</p>
  
  <p>Thanks for your help,
  Coen</p>
  
  <p>Update:
  I tried to SCP with two different non-root user, then the files are detected and picked up.
  I tried to set a umask 0000 on the entire folder, with no effect.</p>