staticvoid prepareTestEnv() throws IOException {
File fileToCreate = new File(TESTFILE); if (!fileToCreate.exists()) if (!fileToCreate.createNewFile()) thrownew RuntimeException("Can't create test file");
}
//If there will be some problem (i.e. ulimits on number of opened files will fail) //then this method will fail with exception and test will be considered as //failed. But allocated fds will be released because the test is executed by //dedicated VM (@run main/othervm). staticvoid openFiles(int fn, File f) throws FileNotFoundException, IOException {
testFIS = new FileInputStream[FDTOOPEN]; for (;;) { if (0 == fn) break;
FileInputStream fis = new FileInputStream(f);
testFIS[--fn] = fis;
}
}
//The bug 8021820 is a Mac specific and because of that test will pass on all //other platforms if (!System.getProperty("os.name").contains("OS X")) { return;
}
//Create test directory with test files
prepareTestEnv();
//Consume FD ids for this java process to overflow the 1024
openFiles(FDTOOPEN,new File(TESTFILE));
//Wait for incoming connection and make the select() used in java.net //classes fail the limitation on FDSET_SIZE
ServerSocket socket = new ServerSocket(0);
//Set the minimal timeout, no one is //going to connect to this server socket
socket.setSoTimeout(1);
// The accept() call will throw SocketException if the // select() has failed due to limitation on fds size, // indicating test failure. A SocketTimeoutException // is expected, so it is caught and ignored, and the test // passes. try {
socket.accept();
} catch (SocketTimeoutException e) { }
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.