From bd283b844399a835ae5f395de416c2a9db48fff6 Mon Sep 17 00:00:00 2001 From: orbiter Date: Thu, 6 Apr 2006 16:28:28 +0000 Subject: [PATCH] fixed bugs: - null pointer exception during startup of a robinson-configured peer - wrong time calculation of default value of re-crawl option git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2005 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/IndexCreate_p.java | 6 +++--- htroot/yacy/hello.java | 2 +- htroot/yacy/message.java | 2 +- htroot/yacy/search.java | 2 +- source/de/anomic/yacy/yacyClient.java | 6 +++--- source/de/anomic/yacy/yacyPeerActions.java | 2 +- source/de/anomic/yacy/yacySeed.java | 14 ++++++++++---- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/htroot/IndexCreate_p.java b/htroot/IndexCreate_p.java index 673391066..89addb84b 100644 --- a/htroot/IndexCreate_p.java +++ b/htroot/IndexCreate_p.java @@ -329,13 +329,13 @@ public class IndexCreate_p { prop.put("crawlingIfOlderNumber", 1); prop.put("crawlingIfOlderUnitYearCheck", 1); } else if (crawlingIfOlder >= 60*24*365) { - prop.put("crawlingIfOlderNumber", crawlingIfOlder / 60*24*365); + prop.put("crawlingIfOlderNumber", crawlingIfOlder / (60*24*365)); prop.put("crawlingIfOlderUnitYearCheck", 1); } else if (crawlingIfOlder >= 60*24*30) { - prop.put("crawlingIfOlderNumber", crawlingIfOlder / 60*24*30); + prop.put("crawlingIfOlderNumber", crawlingIfOlder / (60*24*30)); prop.put("crawlingIfOlderUnitMonthCheck", 1); } else if (crawlingIfOlder >= 60*24) { - prop.put("crawlingIfOlderNumber", crawlingIfOlder / 60*24); + prop.put("crawlingIfOlderNumber", crawlingIfOlder / (60*24)); prop.put("crawlingIfOlderUnitDayCheck", 1); } else if (crawlingIfOlder >= 60) { prop.put("crawlingIfOlderNumber", crawlingIfOlder / 60); diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java index 022aa4b5e..7f968e916 100644 --- a/htroot/yacy/hello.java +++ b/htroot/yacy/hello.java @@ -79,7 +79,7 @@ public final class hello { int count = 0; try {count = (countStr == null) ? 0 : Integer.parseInt(countStr);} catch (NumberFormatException e) {count = 0;} // final Date remoteTime = yacyCore.parseUniversalDate((String) post.get(MYTIME)); // read remote time - final yacySeed remoteSeed = yacySeed.genRemoteSeed(seed, key); + final yacySeed remoteSeed = yacySeed.genRemoteSeed(seed, key, true); // System.out.println("YACYHELLO: REMOTESEED=" + ((remoteSeed == null) ? "NULL" : remoteSeed.toString())); if (remoteSeed == null) { return null; } diff --git a/htroot/yacy/message.java b/htroot/yacy/message.java index 6f7b24f9a..fbdef82d8 100644 --- a/htroot/yacy/message.java +++ b/htroot/yacy/message.java @@ -118,7 +118,7 @@ public final class message { return prop; } //Date remoteTime = yacyCore.parseUniversalDate((String) post.get(yacySeed.MYTIME)); // read remote time - yacySeed otherSeed = yacySeed.genRemoteSeed(otherSeedString, key); + yacySeed otherSeed = yacySeed.genRemoteSeed(otherSeedString, key, true); String subject = crypt.simpleDecode(post.get("subject", ""), key); // message's subject String message = crypt.simpleDecode(post.get("message", ""), key); // message body diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java index b3674f486..dd44fe9de 100644 --- a/htroot/yacy/search.java +++ b/htroot/yacy/search.java @@ -94,7 +94,7 @@ public final class search { if (yacyCore.seedDB == null) { yacyCore.log.logSevere("yacy.search: seed cache not initialized"); } else { - yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(oseed, key), true); + yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(oseed, key, true), true); } // prepare search diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java index e4199ac5e..c0c527400 100644 --- a/source/de/anomic/yacy/yacyClient.java +++ b/source/de/anomic/yacy/yacyClient.java @@ -151,7 +151,7 @@ public final class yacyClient { yacySeed otherPeer = null; float otherPeerVersion = 0; if (otherHash != null && otherHash.length() > 0) { - otherPeer = yacySeed.genRemoteSeed((String) result.get("seed0"), key); + otherPeer = yacySeed.genRemoteSeed((String) result.get("seed0"), key, true); if (otherPeer == null || !otherPeer.hash.equals(otherHash)) { yacyCore.log.logFine("yacyClient.publishMySeed: consistency error: other peer '" + ((otherPeer==null)?"unknown":otherPeer.getName()) + "' wrong"); return -1; // no success @@ -233,7 +233,7 @@ public final class yacyClient { while ((seedStr = (String) result.get(yacySeed.SEED + i++)) != null) { // integrate new seed into own database // the first seed, "seed0" is the seed of the responding peer - if (yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(seedStr, key), (i == 1))) count++; + if (yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(seedStr, key, true), (i == 1))) count++; } return count; } @@ -266,7 +266,7 @@ public final class yacyClient { if (result == null || result.size() == 0) { return null; } //final Date remoteTime = yacyCore.parseUniversalDate((String) result.get(yacySeed.MYTIME)); // read remote time - return yacySeed.genRemoteSeed((String) result.get("response"), key); + return yacySeed.genRemoteSeed((String) result.get("response"), key, true); } catch (Exception e) { yacyCore.log.logSevere("yacyClient.querySeed error:" + e.getMessage()); return null; diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.java index 884f7bd6f..9ef1d5e32 100644 --- a/source/de/anomic/yacy/yacyPeerActions.java +++ b/source/de/anomic/yacy/yacyPeerActions.java @@ -192,7 +192,7 @@ public class yacyPeerActions { enu = seedList.iterator(); lc = 0; while (enu.hasNext()) { - ys = yacySeed.genRemoteSeed((String) enu.next(), null); + ys = yacySeed.genRemoteSeed((String) enu.next(), null, true); if ((ys != null) && (ys.isProper() == null) && ((seedDB.mySeed == null) || (seedDB.mySeed.hash != ys.hash))) { if (connectPeer(ys, false)) lc++; diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java index 81f24e0c9..8e326138a 100644 --- a/source/de/anomic/yacy/yacySeed.java +++ b/source/de/anomic/yacy/yacySeed.java @@ -597,7 +597,7 @@ public class yacySeed { return hash; } - public static yacySeed genRemoteSeed(String seedStr, String key) { + public static yacySeed genRemoteSeed(String seedStr, String key, boolean properTest) { // this method is used to convert the external representation of a seed into a seed object // yacyCore.log.logFinest("genRemoteSeed: seedStr=" + seedStr + " key=" + key); if (seedStr == null) { return null; } @@ -606,8 +606,14 @@ public class yacySeed { final HashMap dna = serverCodings.string2map(seed); final String hash = (String) dna.remove("Hash"); yacySeed resultSeed = new yacySeed(hash, dna); - if (resultSeed.isProper() == null) return resultSeed; - return null; + if (properTest) { + String testResult = resultSeed.isProper(); + if (testResult != null) { + yacyCore.log.logFinest("seed is not proper (" + testResult + "): " + resultSeed); + return null; + } + } + return resultSeed; } public String toString() { @@ -655,7 +661,7 @@ public class yacySeed { final char[] b = new char[(int) f.length()]; fr.read(b, 0, b.length); fr.close(); - return genRemoteSeed(new String(b), null); + return genRemoteSeed(new String(b), null, false); } public Object clone() {