Author: jnioche
Date: Mon Oct 14 09:45:46 2013
New Revision: 1531833

URL: http://svn.apache.org/r1531833
Log:
NUTCH-1606

Modified:
    nutch/trunk/CHANGES.txt
    nutch/trunk/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java
    nutch/trunk/src/java/org/apache/nutch/crawl/SignatureFactory.java
    nutch/trunk/src/java/org/apache/nutch/util/ObjectCache.java

Modified: nutch/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/nutch/trunk/CHANGES.txt?rev=1531833&r1=1531832&r2=1531833&view=diff
==============================================================================
--- nutch/trunk/CHANGES.txt (original)
+++ nutch/trunk/CHANGES.txt Mon Oct 14 09:45:46 2013
@@ -2,6 +2,8 @@ Nutch Change Log
 
 Nutch Development Trunk
 
+* NUTCH-1606 Check that Factory classes use the cache in a thread safe way 
(jnioche)
+
 * NUTCH-1653 AbstractScoringFilter (jnioche)
 
 * NUTCH-1562 Order of execution for scoring filters (jnioche, snagel)

Modified: nutch/trunk/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java
URL: 
http://svn.apache.org/viewvc/nutch/trunk/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java?rev=1531833&r1=1531832&r2=1531833&view=diff
==============================================================================
--- nutch/trunk/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java 
(original)
+++ nutch/trunk/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java Mon 
Oct 14 09:45:46 2013
@@ -30,7 +30,7 @@ public class FetchScheduleFactory {
   private FetchScheduleFactory() {}                   // no public ctor
 
   /** Return the FetchSchedule implementation. */
-  public static FetchSchedule getFetchSchedule(Configuration conf) {
+  public synchronized static FetchSchedule getFetchSchedule(Configuration 
conf) {
     String clazz = conf.get("db.fetch.schedule.class", 
DefaultFetchSchedule.class.getName());
     ObjectCache objectCache = ObjectCache.get(conf);
     FetchSchedule impl = (FetchSchedule)objectCache.getObject(clazz);

Modified: nutch/trunk/src/java/org/apache/nutch/crawl/SignatureFactory.java
URL: 
http://svn.apache.org/viewvc/nutch/trunk/src/java/org/apache/nutch/crawl/SignatureFactory.java?rev=1531833&r1=1531832&r2=1531833&view=diff
==============================================================================
--- nutch/trunk/src/java/org/apache/nutch/crawl/SignatureFactory.java (original)
+++ nutch/trunk/src/java/org/apache/nutch/crawl/SignatureFactory.java Mon Oct 
14 09:45:46 2013
@@ -38,7 +38,7 @@ public class SignatureFactory {
   private SignatureFactory() {}                   // no public ctor
 
   /** Return the default Signature implementation. */
-  public static Signature getSignature(Configuration conf) {
+  public synchronized static Signature getSignature(Configuration conf) {
     String clazz = conf.get("db.signature.class", 
MD5Signature.class.getName());
     ObjectCache objectCache = ObjectCache.get(conf);
     Signature impl = (Signature)objectCache.getObject(clazz);

Modified: nutch/trunk/src/java/org/apache/nutch/util/ObjectCache.java
URL: 
http://svn.apache.org/viewvc/nutch/trunk/src/java/org/apache/nutch/util/ObjectCache.java?rev=1531833&r1=1531832&r2=1531833&view=diff
==============================================================================
--- nutch/trunk/src/java/org/apache/nutch/util/ObjectCache.java (original)
+++ nutch/trunk/src/java/org/apache/nutch/util/ObjectCache.java Mon Oct 14 
09:45:46 2013
@@ -36,7 +36,7 @@ public class ObjectCache {
     objectMap = new HashMap<String, Object>();
   }
   
-  public static ObjectCache get(Configuration conf) {
+  public synchronized static ObjectCache get(Configuration conf) {
     ObjectCache objectCache = CACHE.get(conf);
     if (objectCache == null) {
       LOG.debug("No object cache found for conf=" + conf 
@@ -47,11 +47,11 @@ public class ObjectCache {
     return objectCache;
   }
   
-  public Object getObject(String key) {
+  public synchronized Object getObject(String key) {
     return objectMap.get(key);
   }
   
-  public void setObject(String key, Object value) {
+  public synchronized void setObject(String key, Object value) {
     objectMap.put(key, value);
   }
 }


Reply via email to