Skip to content

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

Bugfix to "-UNRESOLVED_PATTERN- bei Hostname-Änderung" (http://www.yacy-forum.de/viewtopic.php?t=3093)

(no author)24ac4e886013
diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.java
index bd25a2cde..e16c4c5d7 100644
--- a/source/de/anomic/server/serverCore.java
+++ b/source/de/anomic/server/serverCore.java
@@ -466,10 +466,15 @@ public final class serverCore extends serverAbstractThread implements serverThre
public static InetAddress publicLocalIP() {
try {
-
+ String hostName;
+ try {
+ hostName = InetAddress.getLocalHost().getHostName();
+ } catch (java.net.UnknownHostException e) {
+ hostName = "localhost"; // hopin' nothing serious happened only the hostname changed while running yacy
+ System.err.println("ERROR: (internal) " + e.getMessage());
+ }
// list all addresses
- //InetAddress[] ia = InetAddress.getAllByName("localhost");
- InetAddress[] ia = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
+ InetAddress[] ia = InetAddress.getAllByName(hostName);
//for (int i = 0; i < ia.length; i++) System.out.println("IP: " + ia[i].getHostAddress()); // DEBUG
if (ia.length == 0) {
try {