Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

fix NPE in Load_MediawikiWiki servlet in intranet mode - in intranet mode getip returns null causing a NPE - adjust starturl (which was set to http://localip/repository) which is never the start url for the Mediawiki + correct javadoc for seed.getIP()

reger6384b7d82e86
diff --git a/htroot/Load_MediawikiWiki.java b/htroot/Load_MediawikiWiki.java
index 5260a68d6..7474bff83 100644
--- a/htroot/Load_MediawikiWiki.java
+++ b/htroot/Load_MediawikiWiki.java
@@ -26,7 +26,6 @@
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.search.Switchboard;
-import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@@ -38,11 +37,13 @@ public class Load_MediawikiWiki {
final serverObjects prop = new serverObjects();
// define visible variables
- String a = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
- if (a == null) a = "localhost:" + sb.getLocalPort();
- final boolean intranet = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "").equals("intranet");
- final String repository = "http://" + a + "/repository/";
- prop.put("starturl", (intranet) ? repository : "http://");
+ String a;
+ if (sb.peers.myIPs().isEmpty()) {
+ a = "localhost:" + sb.getLocalPort();
+ } else {
+ a = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
+ }
+ prop.put("starturl", "http://");
prop.put("address", a);
// return rewrite properties
diff --git a/source/net/yacy/peers/Seed.java b/source/net/yacy/peers/Seed.java
index 338487853..04a31c6fb 100644
--- a/source/net/yacy/peers/Seed.java
+++ b/source/net/yacy/peers/Seed.java
@@ -344,7 +344,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
/**
* try to get the public IP<br>
*
- * @return the IP or localhost IP (127.0.0.1)
+ * @return the public IP or null
*/
@Deprecated
public final String getIP() {