Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6198547
Votes 0
Synopsis File.createNewFile() on an existing directory incorrectly throws IOException (win)
Category java:classes_io
Reported Against rc
Release Fixed mustang(b75)
State 10-Fix Delivered, Verified, bug
Priority: 3-Medium
Related Bugs 6325169 , 6223181
Submit Date 22-NOV-2004
Description
Simple test case:

public class AccessDenied {
  public static void main(String[] args) {
    try {
      java.io.File file = new java.io.File("hugo");
      boolean result = file.createNewFile();
      System.out.println(result);
    } catch (java.io.IOException ex) {
      System.out.println("Error: " + ex.getMessage());
    }
  }
}

When I run this on either Solaris or Windows and "hugo" does
not exist, I get the expected output "true".

When "hugo" exists and is a file, I get the expected output
"false" on either platform.

When "hugo" exists and is a directory, I get "false" on
Solaris and an "Access is Denied" exception is thrown
on Windows. 

This is a problem for  customer  since their application depends on the
correct behaviour, i. e. the access denied exception as unexpected
behaviour is not acceptable since it introduces a platform 
dependency.
Posted Date : 2006-02-01 07:04:34.0
Work Around
N/A
Evaluation
It is probably best to fix this problem in the native code in order to preserve atomicity with the file creation.  We need to change the handling of the return value for CreateFileW in WinNTFileSystem_md.c.  Parallel changes may also be necessary in Win32FileSystem_md.c
Posted Date : 2006-02-01 07:04:35.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang