1131f35cd1
As explained in 'The "Double-Checked Locking is Broken" Declaration'[*], Java's memory model does not support double-checked locking: class LazyReadableChannel { private ReachableChannel rc = null; public ReadableChannel get() { if (rc == null) { synchronized (this) { if (rc == null) { rc = new ReadableChannel(); } } } return rc; } } With JDK 5 and newer, there is a formal memory model that ensures this works if "rc" is volatile, but it is still not thread-safe without that. Fortunately, this ReadableChannelSupplier is never passed between threads, so it does not need to be thread-safe. Simplify by removing the synchronization. [*] https://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html Change-Id: I0698ee6618d734fc129dd4f63fc047c1c17c94a9 Signed-off-by: Jonathan Nieder <jrn@google.com> |
||
---|---|---|
.. | ||
.settings | ||
META-INF | ||
findBugs | ||
resources/org/eclipse/jgit | ||
src/org/eclipse/jgit | ||
.classpath | ||
.fbprefs | ||
.gitignore | ||
.project | ||
BUILD | ||
about.html | ||
build.properties | ||
plugin.properties | ||
pom.xml |