When doing concurrent ingests we have experienced the occasional
ingest-error. Not that many on Linux systems. but quite a few on Windows
systems. We did a bit of debugging and discovered the following
temporary file naming collision issue, which is indeed easy to trigger
on Windows, as the resolution of System.currentTimeMillis() is 16ms. The
fix is to use the thread-safe File.createTempFile() function.
Proposed patch attached.
--
Morten Grouleff
--------------------------------------------------------------------
Trifork A/S, Margrethepladsen 4, DK-8000 Aarhus C, Denmark.
QCon SF 2008: Nov. 17. - 21. http://qconsf.com/ See you there?
Index: src/java/fedora/server/validation/DOValidatorImpl.java
===================================================================
--- src/java/fedora/server/validation/DOValidatorImpl.java (revision 7780)
+++ src/java/fedora/server/validation/DOValidatorImpl.java (working copy)
@@ -358,14 +358,14 @@
File objectAsFile = null;
try {
File tempDir = new File(dirname);
- String fileLocation = null;
+ File fileLocation = null;
if (tempDir.exists() || tempDir.mkdirs()) {
- fileLocation =
- tempDir.toString() + File.separator
- + System.currentTimeMillis() + ".tmp";
+ fileLocation = File.createTempFile("validation", "tmp", tempDir);
+
FileOutputStream fos = new FileOutputStream(fileLocation);
- FileUtils.copy(objectAsStream, fos);
- objectAsFile = new File(fileLocation);
+ if (FileUtils.copy(objectAsStream, fos)) {
+ objectAsFile = fileLocation;
+ }
}
} catch (IOException e) {
if (objectAsFile.exists()) {
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Fedora-commons-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fedora-commons-developers