From 06b6e35484dd6c3da46615f05567a097f5c9dce6 Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 2 May 2007 12:26:29 +0000 Subject: [PATCH] fix for a null pointer exception if clusters are not defined git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3632 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ViewProfile.java | 2 +- htroot/yacy/hello.java | 2 +- source/de/anomic/plasma/plasmaSwitchboard.java | 6 +++--- source/de/anomic/yacy/yacyDHTAction.java | 2 +- source/de/anomic/yacy/yacySearch.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htroot/ViewProfile.java b/htroot/ViewProfile.java index 5ed68334b..0af82f864 100644 --- a/htroot/ViewProfile.java +++ b/htroot/ViewProfile.java @@ -118,7 +118,7 @@ public class ViewProfile { } catch (IOException e) {} // try to get the profile from remote peer - seed.setAlternativeAddress((String) switchboard.clusterhashes.get(seed.hash)); + if (switchboard.clusterhashes != null) seed.setAlternativeAddress((String) switchboard.clusterhashes.get(seed.hash)); profile = yacyClient.getProfile(seed); // if profile did not arrive, say that peer is disconnected diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java index 205a72706..bac608064 100644 --- a/htroot/yacy/hello.java +++ b/htroot/yacy/hello.java @@ -101,7 +101,7 @@ public final class hello { } int urls = -1; - remoteSeed.setAlternativeAddress((String) sb.clusterhashes.get(remoteSeed.hash)); + if (sb.clusterhashes != null) remoteSeed.setAlternativeAddress((String) sb.clusterhashes.get(remoteSeed.hash)); // if the remote client has reported its own IP address and the client supports // the port forwarding feature (if client version >= 0.383) then we try to diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index 30a5bd633..ee360bc1a 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -2480,7 +2480,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser // if this was performed for a remote crawl request, notify requester if ((processCase == PROCESSCASE_6_GLOBAL_CRAWLING) && (initiatorPeer != null)) { log.logInfo("Sending crawl receipt for '" + entry.normalizedURLString() + "' to " + initiatorPeer.getName()); - initiatorPeer.setAlternativeAddress((String) clusterhashes.get(initiatorPeer.hash)); + if (clusterhashes != null) initiatorPeer.setAlternativeAddress((String) clusterhashes.get(initiatorPeer.hash)); yacyClient.crawlReceipt(initiatorPeer, "crawl", "fill", "indexed", newEntry, ""); } } else { @@ -2495,7 +2495,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser log.logSevere("Could not index URL " + entry.url() + ": " + ee.getMessage(), ee); if ((processCase == PROCESSCASE_6_GLOBAL_CRAWLING) && (initiatorPeer != null)) { - initiatorPeer.setAlternativeAddress((String) clusterhashes.get(initiatorPeer.hash)); + if (clusterhashes != null) initiatorPeer.setAlternativeAddress((String) clusterhashes.get(initiatorPeer.hash)); yacyClient.crawlReceipt(initiatorPeer, "crawl", "exception", ee.getMessage(), null, ""); } addURLtoErrorDB(entry.url(), referrerUrlHash, initiatorPeerHash, docDescription, plasmaCrawlEURL.DENIED_UNSPECIFIED_INDEXING_ERROR, new kelondroBitfield()); @@ -2508,7 +2508,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser log.logInfo("Not indexed any word in URL " + entry.url() + "; cause: " + noIndexReason); addURLtoErrorDB(entry.url(), referrerUrlHash, initiatorPeerHash, docDescription, noIndexReason, new kelondroBitfield()); if ((processCase == PROCESSCASE_6_GLOBAL_CRAWLING) && (initiatorPeer != null)) { - initiatorPeer.setAlternativeAddress((String) clusterhashes.get(initiatorPeer.hash)); + if (clusterhashes != null) initiatorPeer.setAlternativeAddress((String) clusterhashes.get(initiatorPeer.hash)); yacyClient.crawlReceipt(initiatorPeer, "crawl", "rejected", noIndexReason, null, ""); } } diff --git a/source/de/anomic/yacy/yacyDHTAction.java b/source/de/anomic/yacy/yacyDHTAction.java index 20b65fc45..e551ec7ed 100644 --- a/source/de/anomic/yacy/yacyDHTAction.java +++ b/source/de/anomic/yacy/yacyDHTAction.java @@ -222,7 +222,7 @@ public class yacyDHTAction implements yacyPeerAction { while (i.hasNext()) { yacySeed seed = seedDB.getConnected((String) i.next()); if (seed == null) continue; - seed.setAlternativeAddress((String) clusterhashes.get(seed.hash)); + if (clusterhashes != null) seed.setAlternativeAddress((String) clusterhashes.get(seed.hash)); return seed; } return null; diff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.java index 27e7b5e09..7d6094d52 100644 --- a/source/de/anomic/yacy/yacySearch.java +++ b/source/de/anomic/yacy/yacySearch.java @@ -278,7 +278,7 @@ public class yacySearch extends Thread { // prepare seed targets and threads final yacySeed targetPeer = yacyCore.seedDB.getConnected(targethash); if (targetPeer == null) return null; - targetPeer.setAlternativeAddress((String) clusterselection.get(targetPeer.hash)); + if (clusterselection != null) targetPeer.setAlternativeAddress((String) clusterselection.get(targetPeer.hash)); yacySearch searchThread = new yacySearch(wordhashes, excludehashes, urlhashes, "", "", 9999, true, 0, targetPeer, urlManager, wordIndex, containerCache, new TreeMap(), blacklist, snippetCache, timingProfile, rankingProfile, constraint); searchThread.start();