fix for NPE in seed handling

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5371 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent fea82b54ef
commit c6525ab75f

@ -170,6 +170,7 @@ public class yacySeed implements Cloneable {
public yacySeed(final String theHash, final Map<String, String> theDna) {
// create a seed with a pre-defined hash map
assert theHash != null;
this.hash = theHash;
this.dna = theDna;
final String flags = this.dna.get(yacySeed.FLAGS);
@ -901,6 +902,7 @@ public class yacySeed implements Cloneable {
// extract hash
final HashMap<String, String> dna = serverCodings.string2map(seed, ",");
final String hash = dna.remove(yacySeed.HASH);
if (hash == null) return null;
final yacySeed resultSeed = new yacySeed(hash, dna);
// check semantics of content

@ -954,11 +954,13 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
public yacySeed internalNext() {
if ((it == null) || (!(it.hasNext()))) return null;
try {
final Map<String, String> dna = it.next();
if (dna == null) return null;
final String hash = dna.remove("key");
//while (hash.length() < commonHashLength) { hash = hash + "_"; }
return new yacySeed(hash, dna);
while (true) {
final Map<String, String> dna = it.next();
if (dna == null) return null;
final String hash = dna.remove("key");
if (hash == null) { continue; } // bad seed
return new yacySeed(hash, dna);
}
} catch (final Exception e) {
e.printStackTrace();
yacyCore.log.logSevere("ERROR internalNext: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);

Loading…
Cancel
Save