2020 * #L%
2121 */
2222
23+ import java .util .Collections ;
24+
2325import org .json .JSONObject ;
2426
2527import de .taimos .gpsd4java .types .ATTObject ;
@@ -260,6 +262,9 @@ protected IGPSObject parsePOLL(final JSONObject json) throws ParseException {
260262 poll .setTimestamp (this .parseTimestamp (json , "time" ));
261263 } else if (json .has ("timestamp" )) {
262264 poll .setTimestamp (json .optDouble ("timestamp" , Double .NaN ));
265+ } else {
266+ // fallback to current timestamp
267+ poll .setTimestamp (System .currentTimeMillis ());
263268 }
264269
265270 poll .setActive (json .optInt ("active" , 0 ));
@@ -268,16 +273,22 @@ protected IGPSObject parsePOLL(final JSONObject json) throws ParseException {
268273 poll .setFixes (this .parseObjectArray (json .optJSONArray ("tpv" ), TPVObject .class ));
269274 } else if (json .has ("fixes" )) {
270275 poll .setFixes (this .parseObjectArray (json .optJSONArray ("fixes" ), TPVObject .class ));
276+ } else {
277+ poll .setFixes (Collections .<TPVObject >emptyList ());
271278 }
272279
273280 if (json .has ("sky" )) {
274281 poll .setSkyviews (this .parseObjectArray (json .optJSONArray ("sky" ), SKYObject .class ));
275282 } else if (json .has ("skyviews" )) {
276283 poll .setSkyviews (this .parseObjectArray (json .optJSONArray ("skyviews" ), SKYObject .class ));
284+ } else {
285+ poll .setSkyviews (Collections .<SKYObject >emptyList ());
277286 }
278287
279288 if (json .has ("gst" )) {
280289 poll .setGst (this .parseObjectArray (json .optJSONArray ("gst" ), GSTObject .class ));
290+ } else {
291+ poll .setGst (Collections .<GSTObject >emptyList ());
281292 }
282293 gps = poll ;
283294 return gps ;
0 commit comments