From a20b967182f824b98dd39d3e85294fe3d0a7d0d4 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 14 Jun 2018 16:26:26 +1200 Subject: Catch request exceptions (fix #3905) --- src/org/traccar/geocoder/JsonGeocoder.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/geocoder/JsonGeocoder.java b/src/org/traccar/geocoder/JsonGeocoder.java index e06663689..36a3acb76 100644 --- a/src/org/traccar/geocoder/JsonGeocoder.java +++ b/src/org/traccar/geocoder/JsonGeocoder.java @@ -19,6 +19,7 @@ import org.traccar.Context; import org.traccar.helper.Log; import javax.json.JsonObject; +import javax.ws.rs.ClientErrorException; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.InvocationCallback; import java.util.AbstractMap; @@ -62,8 +63,9 @@ public abstract class JsonGeocoder implements Geocoder { } else { if (callback != null) { callback.onFailure(new GeocoderException("Empty address")); + } else { + Log.warning("Empty address"); } - Log.warning("Empty address"); } return null; } @@ -88,7 +90,7 @@ public abstract class JsonGeocoder implements Geocoder { request.async().get(new InvocationCallback() { @Override public void completed(JsonObject json) { - callback.onSuccess(handleResponse(latitude, longitude, json, callback)); + handleResponse(latitude, longitude, json, callback); } @Override @@ -97,7 +99,11 @@ public abstract class JsonGeocoder implements Geocoder { } }); } else { - return handleResponse(latitude, longitude, request.get(JsonObject.class), null); + try { + return handleResponse(latitude, longitude, request.get(JsonObject.class), null); + } catch (ClientErrorException e) { + Log.warning(e); + } } return null; } -- cgit v1.2.3