diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-04 17:42:15 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-04 17:42:36 +1200 |
commit | 7734bfa85228ec85d86a9e1435da568bac0f907b (patch) | |
tree | 2c373ba0702f116ec5b4bd564806819060de0416 /src/org/traccar/web/JsonConverter.java | |
parent | e0fc105c960a5b666e796c047b1efc00222b890b (diff) | |
download | trackermap-server-7734bfa85228ec85d86a9e1435da568bac0f907b.tar.gz trackermap-server-7734bfa85228ec85d86a9e1435da568bac0f907b.tar.bz2 trackermap-server-7734bfa85228ec85d86a9e1435da568bac0f907b.zip |
Fix null list exception
Diffstat (limited to 'src/org/traccar/web/JsonConverter.java')
-rw-r--r-- | src/org/traccar/web/JsonConverter.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/org/traccar/web/JsonConverter.java b/src/org/traccar/web/JsonConverter.java index f9682f90d..19ac6f777 100644 --- a/src/org/traccar/web/JsonConverter.java +++ b/src/org/traccar/web/JsonConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,9 +129,15 @@ public final class JsonConverter { json.add(name, DATE_FORMAT.print(new DateTime(value))); } } else if (method.getReturnType().equals(Map.class)) { - json.add(name, MiscFormatter.toJson((Map) method.invoke(object))); + Map value = (Map) method.invoke(object); + if (value != null) { + json.add(name, MiscFormatter.toJson(value)); + } } else if (method.getReturnType().equals(List.class)) { - json.add(name, arrayToJson((List) method.invoke(object))); + List value = (List) method.invoke(object); + if (value != null) { + json.add(name, arrayToJson(value)); + } } } catch (IllegalAccessException | InvocationTargetException error) { Log.warning(error); |