Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

avoid synchronization in DigestURI hash requests

orbiter078ecacf6181
diff --git a/source/net/yacy/kelondro/data/meta/DigestURI.java b/source/net/yacy/kelondro/data/meta/DigestURI.java
index 4cae92a57..77002ab54 100644
--- a/source/net/yacy/kelondro/data/meta/DigestURI.java
+++ b/source/net/yacy/kelondro/data/meta/DigestURI.java
@@ -152,8 +152,11 @@ public class DigestURI extends MultiProtocolURI implements Serializable {
*/
public final byte[] hash() {
// in case that the object was initialized without a known url hash, compute it now
- synchronized (this) {
- if (this.hash == null) this.hash = urlHashComputation();
+ if (this.hash == null) {
+ // we check the this.hash value twice to avoid synchronization where possible
+ synchronized (this) {
+ if (this.hash == null) this.hash = urlHashComputation();
+ }
}
return this.hash;
}