RFR: JDK-8013827 and JDK-8011950, , java.io.File.createTempFile enters infinite loop when passed invalid data (original) (raw)

Dan Xu dan.xu at oracle.com
Sun Jun 2 02:16:43 UTC 2013


On 06/01/2013 03:05 AM, Alan Bateman wrote:

On 31/05/2013 19:15, Dan Xu wrote:

On 05/29/2013 04:54 AM, Alan Bateman wrote: Thanks for taking this one.

The changes mean that IAE is now thrown for cases where it wasn't thrown previously and I'm wondering if this is worth doing. It might be simpler to just throw IOException on the grounds that creating the file will fail. One other thing to consider is that "" is a valid name of a file on some platforms. I suspect you'll need to delegate to the FileSystem to check the suffix/prefix. Alternatively in TempDirectory.generateFile you could create a File from prefix/n/suffix and call getName to check that its matches. If not then throw an exception. -Alan. Thanks for your good review. I have updated my changes. And it is uploaded at, http://cr.openjdk.java.net/~dxu/8013827/webrev.01/. This updated changes look good, minor nit in that the missing space in two occurrences of "if(". For the test SpecialTempFile then I wonder if the 2s is sufficient, I could imagine this test failing intermittently when under load. Is a thread pool even needed because with the fix then createFileTemp should either work or throw an IOException (no hang). -Alan Thanks, Alan. I am going to fix the format issue on "if(".

As for the SpecialTempFile testcase, I wonder whether these regression tests may happen to be used to test earlier JDK versions. In that case, the thread pool will help the test framework find the test failure easily. Otherwise, I agree it adds extra overhead into this test.

-Dan



More information about the core-libs-dev mailing list