Apache Nutch is an extensible and scalable web crawler
NUTCH-1606
Julien Nioche57f95568e849
diff --git a/CHANGES.txt b/CHANGES.txtindex 5e4abf96b..62012004a 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change LogNutch 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)diff --git a/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java b/src/java/org/apache/nutch/crawl/FetchScheduleFactory.javaindex 175f47b70..0657c37ac 100755--- a/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java+++ b/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java@@ -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);diff --git a/src/java/org/apache/nutch/crawl/SignatureFactory.java b/src/java/org/apache/nutch/crawl/SignatureFactory.javaindex 17bb84b50..1a66063fd 100644--- a/src/java/org/apache/nutch/crawl/SignatureFactory.java+++ b/src/java/org/apache/nutch/crawl/SignatureFactory.java@@ -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);diff --git a/src/java/org/apache/nutch/util/ObjectCache.java b/src/java/org/apache/nutch/util/ObjectCache.javaindex d601a03d7..7cb7b5772 100644--- a/src/java/org/apache/nutch/util/ObjectCache.java+++ b/src/java/org/apache/nutch/util/ObjectCache.java@@ -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);}}