diff --git a/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java b/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java
index cdc9438..2a36292 100644
--- a/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java
+++ b/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java
@@ -27,6 +27,7 @@ import java.net.URI;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.xmlgraphics.io.Resource;
 import org.apache.xmlgraphics.io.ResourceResolver;
@@ -161,10 +162,29 @@ public final class ResourceResolverFactory {
     }
 
     private static class DefaultTempResourceResolver implements TempResourceResolver {
-        private static File getTempFile(String path) throws IOException {
-            File file = new File(System.getProperty("java.io.tmpdir"), path);
-            file.deleteOnExit();
-            return file;
+        private final ConcurrentHashMap<String, File> tempFiles = new ConcurrentHashMap<String, File>();
+
+        private File getTempFile(String uri) throws IOException {
+            File tempFile = tempFiles.get(uri);
+            if (tempFile == null) {
+                throw new IOException(uri + " was never created or has been deleted");
+            }
+            return tempFile;
+        }
+
+        private File createTempFile(String path) throws IOException {
+            File tempFile = File.createTempFile(path, ".fop.tmp");
+            tempFile.deleteOnExit();
+            File oldFile = tempFiles.put(path, tempFile);
+            if (oldFile != null) {
+                String errorMsg = oldFile.getAbsolutePath() + " has been already created for " + path;
+                boolean newTempDeleted = tempFile.delete();
+                if (!newTempDeleted) {
+                    errorMsg += ". " + tempFile.getAbsolutePath() + " was not deleted.";
+                }
+                throw new IOException(errorMsg);
+            }
+            return tempFile;
         }
 
         /** {@inheritDoc} */
@@ -174,12 +194,7 @@ public final class ResourceResolverFactory {
 
         /** {@inheritDoc} */
         public OutputStream getOutputStream(String id) throws IOException {
-            File file = getTempFile(id);
-            if (file.createNewFile()) {
-                return new FileOutputStream(file);
-            } else {
-                throw new IOException("Filed to create temporary file: " + id);
-            }
+            return new FileOutputStream(createTempFile(id));
         }
     }
 
