This is the mail archive of the java-patches@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: File.createTempFile fixes


Anthony> This patch sets the java.io.tmpdir property based on the
Anthony> TMPDIR environment variable.

Cool, thanks.

Anthony> The 1.3 docs says that createTempFile throws an exception if
Anthony> "a security manager exists and its
Anthony> SecurityManager.checkWrite(java.io.FileDescriptor) method
Anthony> does not allow a file to be created".  I'm confused.  Doesn't
Anthony> the fact that we have a FileDescriptor mean the file has been
Anthony> created already?

I don't understand this either.
I think your approach is reasonable.

I don't think there's any need to synchronize on tmpdir in the method.
We're just as likely to be racing against some other process.  That
means we need to handle synchronization by using an atomic open
operation.

We almost do this right now, using FileDescriptor.EXCL.  However I
don't think we can currently detect when FileDescriptor.open fails
due to EEXIST as opposed to any other sort of error.  Yuck.

Tom

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]