jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Müller <thomas.muel...@day.com>
Subject Re: clustered environment, 2 different jvms, TransientFileFactory, storing file blobs in db
Date Thu, 08 Apr 2010 08:52:21 GMT

Stefan is right, File.createTempFile() doesn't generate colliding
files. However, there is a potential problem with the
TransientFileFactory. Consider the following case:

- The file "bin-1.tmp" is created (BLOBInTempFile line 51).
- The TransientFileFactory adds a PhantomReference "A" in its queue.
- BLOBInTempFile.delete() or dispose() is called, the file "bin-1.tmp"
is deleted.
- A new file is created, and also called "bin-1.tmp" is created
(BLOBInTempFile line 51)
  (that's possible because File.createTempFile can re-use file names).
- The TransientFileFactory adds a second PhantomReference "B" in its
queue, pointing
  to a different file with the same name.
- The first (only the first) BLOBInTempFile is no longer referenced.
- The TransientFileFactory.ReaperThread gets PhantomReference "A" and
  deletes this file. But the file is still used and referenced ("B").

I'm not sure if this is what is happening in your case, but it is a
potential problem.

Could you log a bug?

There are multiple ways to solve the problem. I think the best
solution is to not use File.createTempFile() and instead use our own
file name factory (with a random part, and an counter part).


View raw message