Wednesday, August 12, 2009

A trip to... temp files...

Who would have thought that temp files deserved my attention so that I actually blog about it, yet this topic can be... not unimportant :)

Anyways... thinking of portability of java apps some of past projects came to my mind where I needed to run Orbeon app with JBoss on Mac OS-X. Seems to be no big deal right? Well... behold!

The thing is... the app uses temp files according to which seem to be not a big deal but it kinda gets in your way when you try to load the file back via URLConnection and some (probaly URL) decoding of the file path has happen on the way. Mostly (in this case) this goes unpunished... While this is obviously bug in the application that's not the point...

What goes wrong? What does go wrong is that the jvm on Mac OS-X uses the default temp dir which contains several '+' characters (?!) in the path, e.g.:


This is actually easy to 'fix' (besides fixing the code, of course :) by overriding the default temp dir location and feeding variable to the JVM but still the situation was amused me for some reason. I am wondering if anyone knows the reason behind such creativity?

Thus, a word of caution: watch out for temp files on OS-X :)