-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b04
-
generic
-
generic
-
Verified
SYNOPSIS
--------
NIO2 Misleading maximum WatchServices error message
OPERATING SYSTEM
----------------
Linux
FULL JDK VERSION
----------------
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b146)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b16, mixed mode)
DESCRIPTION from LICENSEE
-------------------------
By default, the OS settings on linux kernels which support the inotify mechanism only allow 128 of these to be created.
The number set can be found by cat'ing the file:
/proc/sys/fs/inotify/max_user_instances
The WatchService API in JDK 7 will take advantage of the inotify mechanism if the kernel version supports it. If too many WatchServices are instantiated, using up all available inotify resources, the following exception is thrown:
java.io.IOException: Too many open files
at sun.nio.fs.LinuxWatchService.<init>(LinuxWatchService.java:61)
at sun.nio.fs.LinuxFileSystem.newWatchService(LinuxFileSystem.java:47)
at tests.com.ibm.jtc.nio2.unstable.CreateWatchServices.testCreateSomeWatchServices(CreateWatchServices.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:76)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
This exception isn't very useful, because it appears to indicate that the system has run out of file handles, but that's not the case. It would be nicer if the message read something like "Maximum inotify instances reached". At least this way the user can search for the command to modify the upper limit so that their application will run as expected.
STEPS TO REPRODUCE:
-------------------
Compile and run the attached testcase.
TESTCASE
--------
import java.nio.file.*;
import java.io.*;
class Test {
public static void main(String[] arg) throws Exception {
for (int i = 0; i < 1000; i++) {
System.out.println(i);
WatchService watchService = FileSystems.getDefault().newWatchService();
Thread.sleep(100);
}
}
}
--------
NIO2 Misleading maximum WatchServices error message
OPERATING SYSTEM
----------------
Linux
FULL JDK VERSION
----------------
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b146)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b16, mixed mode)
DESCRIPTION from LICENSEE
-------------------------
By default, the OS settings on linux kernels which support the inotify mechanism only allow 128 of these to be created.
The number set can be found by cat'ing the file:
/proc/sys/fs/inotify/max_user_instances
The WatchService API in JDK 7 will take advantage of the inotify mechanism if the kernel version supports it. If too many WatchServices are instantiated, using up all available inotify resources, the following exception is thrown:
java.io.IOException: Too many open files
at sun.nio.fs.LinuxWatchService.<init>(LinuxWatchService.java:61)
at sun.nio.fs.LinuxFileSystem.newWatchService(LinuxFileSystem.java:47)
at tests.com.ibm.jtc.nio2.unstable.CreateWatchServices.testCreateSomeWatchServices(CreateWatchServices.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:76)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
This exception isn't very useful, because it appears to indicate that the system has run out of file handles, but that's not the case. It would be nicer if the message read something like "Maximum inotify instances reached". At least this way the user can search for the command to modify the upper limit so that their application will run as expected.
STEPS TO REPRODUCE:
-------------------
Compile and run the attached testcase.
TESTCASE
--------
import java.nio.file.*;
import java.io.*;
class Test {
public static void main(String[] arg) throws Exception {
for (int i = 0; i < 1000; i++) {
System.out.println(i);
WatchService watchService = FileSystems.getDefault().newWatchService();
Thread.sleep(100);
}
}
}