diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-08 22:50:39 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-08 22:50:39 +1300 |
commit | c99e32bb5da8a19c19c13e871d5c7b843b2bd182 (patch) | |
tree | e36ad02ab99876e1cdcc2db0a58b74fbb6ef27de | |
parent | 1264391afbf2407b5ea406f3b540ca34cb667543 (diff) | |
download | traccar-server-c99e32bb5da8a19c19c13e871d5c7b843b2bd182.tar.gz traccar-server-c99e32bb5da8a19c19c13e871d5c7b843b2bd182.tar.bz2 traccar-server-c99e32bb5da8a19c19c13e871d5c7b843b2bd182.zip |
Check for null in query builder
-rw-r--r-- | src/org/traccar/database/QueryBuilder.java | 5 | ||||
-rw-r--r-- | test/org/traccar/protocol/RuptelaProtocolDecoderTest.java | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java index 11dbcd1b9..5846d4285 100644 --- a/src/org/traccar/database/QueryBuilder.java +++ b/src/org/traccar/database/QueryBuilder.java @@ -374,7 +374,10 @@ public class QueryBuilder { @Override public void process(T object, ResultSet resultSet) throws SQLException { try { - method.invoke(object, new Date(resultSet.getTimestamp(name).getTime())); + Timestamp timestamp = resultSet.getTimestamp(name); + if (timestamp != null) { + method.invoke(object, new Date(timestamp.getTime())); + } } catch (IllegalAccessException | InvocationTargetException error) { Log.warning(error); } diff --git a/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java b/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java index 2012edc76..1a9153ec2 100644 --- a/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java +++ b/test/org/traccar/protocol/RuptelaProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class RuptelaProtocolDecoderTest extends ProtocolDecoderTest { public void testDecode() throws Exception { RuptelaProtocolDecoder decoder = new RuptelaProtocolDecoder(new RuptelaProtocol()); + + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString( + "0050000310f5615f419c0100015613d8ed0000fff5b37a035af37801e700000900000d07071b0c020003001c01202cad000500064302a81d33e61e100116317cd3ffff174ad60241000077fa960000f232003c2e")))); verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertHexString( "00560003116e7438a7a50100015565cbb9000020fd21300f113f4600005f000600090d090805011b13cf00020003001c012029ad00041d31dd1e0ebd160000c50000047200000000d0000000004100016a2a960000a5a300c9ee")))); |