On Wed, Nov 4, 2009 at 4:11 AM, Tim Ellison <[email protected]> wrote:
> Like everyone else, I'm avoiding studying sources of Sun code, so can
> you show the test case here (or on a JIRA)?
>
I attached it in the first message, but it looks like the mailing list
software silently discards attachments. Here's the test inline:
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class Scratch {
public static void main(String[] args) throws Exception {
new ProcessBuilder()
.command("/usr/bin/hdiutil", "create", "-fs", "HFS+", "-size",
"10m",
"-volname", "refreshing", "-attach", "/tmp/refreshing.dmg")
.start()
.waitFor();
ChmoddedFileMaker coke = new
ChmoddedFileMaker("/Volumes/refreshing/refreshing.txt");
ChmoddedFileMaker pepsi = new
ChmoddedFileMaker("/Volumes/refreshing/refreshing.txt");
// this write will succeed because the volume exists
coke.writeAndChmod("Coke");
new ProcessBuilder().command("/sbin/umount", "-f",
"/Volumes/refreshing/")
.start()
.waitFor();
// this write will fail because the volume has disappeared
pepsi.writeAndChmod("Pepsi");
}
static class ChmoddedFileMaker {
private final String file;
private final OutputStream out;
ChmoddedFileMaker(String file) throws FileNotFoundException {
this.file = file;
this.out = new BufferedOutputStream(new FileOutputStream(this.file));
}
void writeAndChmod(String contents) throws IOException,
InterruptedException {
out.write(contents.getBytes());
out.close();
}
}
}
When this program is executed on the RI, the 2nd write fails but no
exceptions are thrown.