diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2022-01-15 23:45:02 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2022-01-15 23:45:02 -0800 |
commit | 071f038906ebcd29a42803e32ffe65efde57dbb6 (patch) | |
tree | 38adc7021df441daa1fc686c80e5373a18be54a7 | |
parent | 93a341b3232863161f9422beae34f0782dc86a29 (diff) | |
download | trackermap-server-071f038906ebcd29a42803e32ffe65efde57dbb6.tar.gz trackermap-server-071f038906ebcd29a42803e32ffe65efde57dbb6.tar.bz2 trackermap-server-071f038906ebcd29a42803e32ffe65efde57dbb6.zip |
Handle null pointer
-rw-r--r-- | src/main/java/org/traccar/protocol/OrbcommProtocolDecoder.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/OrbcommProtocolDecoder.java b/src/main/java/org/traccar/protocol/OrbcommProtocolDecoder.java index 8f828beff..daef923b0 100644 --- a/src/main/java/org/traccar/protocol/OrbcommProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/OrbcommProtocolDecoder.java @@ -44,11 +44,14 @@ public class OrbcommProtocolDecoder extends BaseProtocolDecoder { String content = response.content().toString(StandardCharsets.UTF_8); JsonObject json = Json.createReader(new StringReader(content)).readObject(); - OrbcommProtocolPoller poller = BasePipelineFactory.getHandler(channel.pipeline(), OrbcommProtocolPoller.class); - if (poller != null) { - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - poller.setStartTime(dateFormat.parse(json.getString("NextStartUTC"))); + if (channel != null) { + OrbcommProtocolPoller poller = + BasePipelineFactory.getHandler(channel.pipeline(), OrbcommProtocolPoller.class); + if (poller != null) { + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + poller.setStartTime(dateFormat.parse(json.getString("NextStartUTC"))); + } } return null; |