7060790: (fs) FileSystem.newWatchService error message confusing when maximum inotify descriptors reached
authoralanb
Sat, 27 Aug 2011 15:40:45 +0100
changeset 10368 79494b8dc2b1
parent 10367 d61bc9ec5dce
child 10369 e9d2e59e53f0
child 10417 947e9a7bf244
7060790: (fs) FileSystem.newWatchService error message confusing when maximum inotify descriptors reached Reviewed-by: forax
jdk/src/solaris/classes/sun/nio/fs/LinuxWatchService.java
jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c
--- a/jdk/src/solaris/classes/sun/nio/fs/LinuxWatchService.java	Sat Aug 27 02:17:33 2011 -0700
+++ b/jdk/src/solaris/classes/sun/nio/fs/LinuxWatchService.java	Sat Aug 27 15:40:45 2011 +0100
@@ -58,7 +58,10 @@
         try {
             ifd = inotifyInit();
         } catch (UnixException x) {
-            throw new IOException(x.errorString());
+            String msg = (x.errno() == EMFILE) ?
+                "User limit of inotify instances reached or too many open files" :
+                x.errorString();
+            throw new IOException(msg);
         }
 
         // configure inotify to be non-blocking
--- a/jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c	Sat Aug 27 02:17:33 2011 -0700
+++ b/jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c	Sat Aug 27 15:40:45 2011 +0100
@@ -108,6 +108,7 @@
     DEF(EROFS);
     DEF(ENODATA);
     DEF(ERANGE);
+    DEF(EMFILE);
 
     // flags used with openat/unlinkat/etc.
 #if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_REMOVEDIR)