abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r556220 - /incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/cache/SimpleCacheKey.java
Date Sat, 14 Jul 2007 04:15:12 GMT
Author: jmsnell
Date: Fri Jul 13 21:15:10 2007
New Revision: 556220

URL: http://svn.apache.org/viewvc?view=rev&rev=556220
Log:
synchronize access to the shared MessageDigest instance

Modified:
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/cache/SimpleCacheKey.java

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/cache/SimpleCacheKey.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/cache/SimpleCacheKey.java?view=diff&rev=556220&r1=556219&r2=556220
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/cache/SimpleCacheKey.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/cache/SimpleCacheKey.java
Fri Jul 13 21:15:10 2007
@@ -27,19 +27,22 @@
 
   private static final long serialVersionUID = 8757289485580165536L;
   private static MessageDigest md;
+  static {
+    try {
+      md = MessageDigest.getInstance("md5");
+    } catch (Exception e) {}
+  }
   
   private final byte[] key;
   
   public SimpleCacheKey(String uri) {
-    key = getMessageDigest().digest(uri.getBytes());
+    MessageDigest md = getMessageDigest();
+    synchronized(md) {
+      key = getMessageDigest().digest(uri.getBytes());
+    }
   }
   
   private static MessageDigest getMessageDigest() {
-    if (md == null) {
-      try {
-        md = MessageDigest.getInstance("md5");
-      } catch (Exception e) {}
-    }
     return md;
   }
   



Mime
View raw message