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()
pull/56/head
reger 9 years ago
parent bfd4e5f9e5
commit 6384b7d82e

@ -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

@ -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() {

Loading…
Cancel
Save