United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-8014394 : (fs) WatchService failing when watching \\server\$d

Details
Type:
Bug
Submit Date:
2013-05-11
Status:
Closed
Updated Date:
2014-02-12
Project Name:
JDK
Resolved Date:
2013-05-27
Component:
core-libs
OS:
Sub-Component:
java.nio
CPU:
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version  " 1.7.0_21 " 
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
Windows 2008 R2 Standard sp1

EXTRA RELEVANT SYSTEM CONFIGURATION :
I've tested the program http://docs.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java on several servers, both physical and virtual, domain members and standalone with the same result. All most probably have a few things in common (install media, antivirus software, etc).

A DESCRIPTION OF THE PROBLEM :
* Download http://docs.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java
* Compile WatchDir.java
* Execute: java WatchDir c:\ <= Works
* Execute java WatchDir d:\ <= Works
* Execute java WatchDir \\<name_of_host>\c$ <= Works
* Execute java WatchDir \\<name_of_host>\d$ <= Doesn't work
* Create directory c:\temp\c and share as c
* Create directory d:\temp\d and share as c
* Execute java WatchDir \\<name_of_host>\c <= Works
* Execute java WatchDir \\<name_of_host>\c <= Doesnt work
This also goes for shares on remote hosts. Shares on the c:\ drive works, shares on other drives doesn't work.

Whe WatchDir doesn't work it silently exists after less than a seconds as key.reset(); returns false.

I can find no obvious reason for this when looking at the network traffic with WireShark. What I see is that when accessing \\..\c$ a  " Notify Request File: "  package is sent. This package is not sent when accessing \\...\d$.

A Powershell Filesystemwatcher program does not have the same problem. The Java developer developing some software for us has not been able to reproduce this behaviour on their system.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
* Install Windows 2008 R2 sp1
* Install jdk 1.7.0_21-b11
* Downoad and compile http://docs.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java
* Execute java WatchDir \\<name_of_host>\c$ <= Works
* Execute java WatchDir \\<name_of_host>\d$ <= Exits in less than a second

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
WatchDir should work in the same way both for shares on c:\ and for shares on d:\.
ACTUAL -
WatchDir works with file shares on c:\, but not with file shares on d:\ (or other drives).

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
http://docs.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Implement an old fashioned file polling object.
                                    

Comments
Verified by manual execute WatchDir.java 
                                     
2013-07-26
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/d78f91ab0e96
User:  lana
Date:  2013-06-04 17:27:56 +0000

                                     
2013-06-04
URL:   http://hg.openjdk.java.net/jdk8/tl/jdk/rev/d78f91ab0e96
User:  uta
Date:  2013-05-27 11:27:21 +0000

                                     
2013-05-27
Normalized manual test as NB project is in the attachment (JDK-8014394.zip).  The share test uses localhost and secondary disk. The issue does not happen with primary shared disk (\\localhost\c$). That is MS magic.
                                     
2013-05-22
Perfect blog record about the related problem.
http://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw_19.html

"ReadDirectoryChangesW fails with ERROR_INVALID_PARAMETER when the buffer length is greater than 64 KB and the application is monitoring a directory over the network. This is due to a packet size limitation with the underlying file sharing protocols."
                                     
2013-05-20
For resource like [\\localhost\j$] we got [STATUS_MORE_PROCESSING_REQUIRED:=:ERROR_MORE_DATA] status on the [GetQueuedCompletionStatus] call. 

That is normal: 
http://stackoverflow.com/questions/3130785/when-are-io-completion-port-packets-sent-and-when-not
, but need additional treatment.
                                     
2013-05-20
The WatchService implementation on Windows uses ReadDirectoryChangesW. From the description it sounds like this is failing asynchronously and this is causing the key is canceled (which is the right behavior for this case). Unfortunately the API doesn't have the ability to report back errors after the registration has completed so it will need more investigation to understand why it is failing in the submitter environment.
                                     
2013-05-12



Hardware and Software, Engineered to Work Together