aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-02-19 12:28:35 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-02-19 12:28:35 +1300
commitdad81d8093e83eaa17224d33d2fc6185c9d32088 (patch)
treea296d316ee9ca41689d05a3c9fc1cbba02a79f4f /src/org/traccar
parentd5bd395f19ef5ed6732b32a0e8d0eb5e6a25c33e (diff)
downloadtraccar-server-dad81d8093e83eaa17224d33d2fc6185c9d32088.tar.gz
traccar-server-dad81d8093e83eaa17224d33d2fc6185c9d32088.tar.bz2
traccar-server-dad81d8093e83eaa17224d33d2fc6185c9d32088.zip
Handle unknown host exception
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/Context.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index c9c2e633e..27e61d32d 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
import com.ning.http.client.AsyncHttpClient;
import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.Properties;
import org.apache.velocity.app.VelocityEngine;
@@ -281,9 +282,14 @@ public final class Context {
velocityProperties.setProperty("runtime.log.logsystem.class",
"org.apache.velocity.runtime.log.NullLogChute");
- String address = config.getString("web.address", InetAddress.getLocalHost().getHostAddress());
- int port = config.getInteger("web.port", 8082);
- String webUrl = URIUtil.newURI("http", address, port, "", "");
+ String address;
+ try {
+ address = config.getString("web.address", InetAddress.getLocalHost().getHostAddress());
+ } catch (UnknownHostException e) {
+ address = "localhost";
+ }
+
+ String webUrl = URIUtil.newURI("http", address, config.getInteger("web.port", 8082), "", "");
webUrl = Context.getConfig().getString("web.url", webUrl);
velocityProperties.setProperty("web.url", webUrl);