aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-26 09:55:39 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-26 09:55:39 +1200
commit8a5afddcf7c4d9624045d8d5e8e323675dbe3a40 (patch)
treec310f60a8c70909a5d02d9d45fef392437d3b16d
parenta6d6797aad992068406bfcfaeb2290662951fa41 (diff)
downloadtrackermap-server-8a5afddcf7c4d9624045d8d5e8e323675dbe3a40.tar.gz
trackermap-server-8a5afddcf7c4d9624045d8d5e8e323675dbe3a40.tar.bz2
trackermap-server-8a5afddcf7c4d9624045d8d5e8e323675dbe3a40.zip
Another attempt to fix geocoding
-rw-r--r--src/org/traccar/geocode/JsonReverseGeocoder.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/org/traccar/geocode/JsonReverseGeocoder.java b/src/org/traccar/geocode/JsonReverseGeocoder.java
index 684bfa0c1..feaaaa0ed 100644
--- a/src/org/traccar/geocode/JsonReverseGeocoder.java
+++ b/src/org/traccar/geocode/JsonReverseGeocoder.java
@@ -19,6 +19,7 @@ import org.traccar.helper.Log;
import javax.json.Json;
import javax.json.JsonObject;
+import javax.json.JsonReader;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
@@ -38,10 +39,13 @@ public abstract class JsonReverseGeocoder implements ReverseGeocoder {
try {
HttpURLConnection conn = (HttpURLConnection) new URL(String.format(url, latitude, longitude)).openConnection();
+ conn.setRequestProperty("Connection", "close"); // don't keep-alive connections
try {
- Reader reader = new InputStreamReader(conn.getInputStream());
+ InputStreamReader streamReader = new InputStreamReader(conn.getInputStream());
+ JsonReader reader = Json.createReader(streamReader);
try {
- Address address = parseAddress(Json.createReader(reader).readObject());
+ Address address = parseAddress(reader.readObject());
+ while (streamReader.read() > 0); // make sure we reached the end
if (address != null) {
return format.format(address);
}