From c78b3a3478bbedd84ff2fac13a2577a6e1793ec3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 8 Jul 2016 19:55:44 +1200 Subject: Add null check to query builder --- src/org/traccar/database/QueryBuilder.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/org/traccar/database') diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java index c5a682b7e..73569ac2a 100644 --- a/src/org/traccar/database/QueryBuilder.java +++ b/src/org/traccar/database/QueryBuilder.java @@ -357,10 +357,13 @@ public final class QueryBuilder { processors.add(new ResultSetProcessor() { @Override public void process(T object, ResultSet resultSet) throws SQLException { - try (JsonReader reader = Json.createReader(new StringReader(resultSet.getString(name)))) { - method.invoke(object, MiscFormatter.fromJson(reader.readObject())); - } catch (IllegalAccessException | InvocationTargetException | JsonParsingException error) { - Log.warning(error); + String value = resultSet.getString(name); + if (value != null) { + try (JsonReader reader = Json.createReader(new StringReader(value))) { + method.invoke(object, MiscFormatter.fromJson(reader.readObject())); + } catch (IllegalAccessException | InvocationTargetException | JsonParsingException error) { + Log.warning(error); + } } } }); -- cgit v1.2.3