Fix invalid "double checked locking" in InflaterCache
commit96b5ad1242a6ad2f8e98960e95c69e5aaf63091e
authorShawn O. Pearce <spearce@spearce.org>
Tue, 23 Dec 2008 00:27:11 +0000 (22 16:27 -0800)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Sun, 4 Jan 2009 00:01:48 +0000 (4 01:01 +0100)
tree99ea4462b7f1fdae0ad31ab311e3048a1a6acedc
parentff13608f7b9eee01caee7a31decb346ea864801c
Fix invalid "double checked locking" in InflaterCache

We move the Inflater allocation out of the synchronized block as
it requires JNI code to build the libz structure.  This permits
other threads to get into the Inflater allocation faster.

We also fix the release implementation to validate the array size
only after we enter the lock, rather than before.  This prevents
us from releasing an inflater due to a stale copy of the open
count being in our processor cache.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit/src/org/spearce/jgit/lib/InflaterCache.java