From 6384b7d82e86e405f95cd76bf69856a60c9de899 Mon Sep 17 00:00:00 2001 From: reger Date: Fri, 27 May 2016 03:10:25 +0200 Subject: [PATCH] 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() --- htroot/Load_MediawikiWiki.java | 13 +++++++------ source/net/yacy/peers/Seed.java | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) 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, Comparator /** * try to get the public IP
* - * @return the IP or localhost IP (127.0.0.1) + * @return the public IP or null */ @Deprecated public final String getIP() {