From 071f038906ebcd29a42803e32ffe65efde57dbb6 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 15 Jan 2022 23:45:02 -0800 Subject: Handle null pointer --- .../java/org/traccar/protocol/OrbcommProtocolDecoder.java | 13 ++++++++----- 1 file 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; -- cgit v1.2.3