From 078ecacf6181f7e4cc87f9891e9f3a729025038a Mon Sep 17 00:00:00 2001 From: orbiter Date: Tue, 15 Mar 2011 00:47:30 +0000 Subject: [PATCH] avoid synchronization in DigestURI hash requests git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7599 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/net/yacy/kelondro/data/meta/DigestURI.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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; }