From 7734bfa85228ec85d86a9e1435da568bac0f907b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 4 Jul 2016 17:42:15 +1200 Subject: Fix null list exception --- src/org/traccar/web/JsonConverter.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/org') 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); -- cgit v1.2.3