RFR: JDK-8013827 and JDK-8011950, , java.io.File.createTempFile enters infinite loop when passed invalid data
Alan Bateman
Alan.Bateman at oracle.com
Sat Jun 1 10:05:34 UTC 2013
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
More information about the core-libs-dev
mailing list