plasma-umass / doppio

Breaks the browser language barrier (includes a plugin-free JVM).

Home Page:http://plasma-umass.github.io/doppio-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error creating temp files with Files.createTempFile()

marcosscriven opened this issue · comments

I've found an issue creating temp files (which I think may be related to work merged in #385)

The following works:

File.createTempFile("test", null);

However, this doesn't:

Files.createTempFile("test", null);

Resulting instead in:

java.nio.file.NoSuchFileException: /tmp/test21774805033540269379
 at sun.nio.fs.UnixNativeDispatcher.open0(Native Method)
 at sun.nio.fs.UnixNativeDispatcher.open(UnixNativeDispatcher.java:71)
 at sun.nio.fs.UnixChannelFactory.open(UnixChannelFactory.java:257)
 at sun.nio.fs.UnixChannelFactory.newFileChannel(UnixChannelFactory.java:136)
 at sun.nio.fs.UnixChannelFactory.newFileChannel(UnixChannelFactory.java:148)
 at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:212)
 at java.nio.file.Files.newByteChannel(Files.java:361)
 at java.nio.file.Files.createFile(Files.java:632)
 at java.nio.file.TempFileHelper.create(TempFileHelper.java:138)
 at java.nio.file.TempFileHelper.createTempFile(TempFileHelper.java:161)
 at java.nio.file.Files.createTempFile(Files.java:897)
 at TempFileTest.main(TempFileTest.java:25)

This trace is somewhat odd, as creating a new temp file should not result in failing if the file doesn't exist. Digging into a local JVM it looks like it tries to do some tests with Posix file permissions which may not be as expected in the Doppio/BrowserFS context.

Unfortunately I can't avoid this as the code I'm using invokes javax.imageio.ImageIO.read(), which attempts to create a temporary cache file using the latter method.

Just as an aside, for anyone looking at this in future, a workaround for avoiding temp file issues in ImageIO is: ImageIO.setUseCache(false)

See https://github.com/openjdk-mirror/jdk/blob/jdk8u/jdk8u/master/src/share/classes/javax/imageio/ImageIO.java#L357

For some reason, my code translates the request into an open() call with r set. Investigating...

I found the issue. I was not converting open() arguments into Node's string-based fopen() flags properly; I used an incorrect mask.

I also discovered I'm missing a chunk of simple nio natives. I'm beefing up unit test coverage and adding those missing methods right now.