From 59bda74e88ec95890cb13d54aefef38e27411c01 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 17 Aug 2022 17:06:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E8=8E=B7=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E4=BD=93=E5=86=85=E5=AE=B9=E4=B8=BA=E7=A9=BA=E6=97=B6?= =?UTF-8?q?=E9=80=A0=E6=88=90=E7=9A=84=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/impl/NotifyRequestProcessor.java | 16 ++++++++++++++-- .../request/impl/SubscribeRequestProcessor.java | 4 ++++ .../impl/message/MessageRequestProcessor.java | 5 +++++ .../cmd/MobilePositionNotifyMessageHandler.java | 2 +- .../cmd/CatalogResponseMessageHandler.java | 2 +- .../cmd/DeviceInfoResponseMessageHandler.java | 2 +- .../MobilePositionResponseMessageHandler.java | 2 +- .../cmd/PresetQueryResponseMessageHandler.java | 2 +- .../cmd/RecordInfoResponseMessageHandler.java | 2 +- 9 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java index ac39dd65..dc7689c9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java @@ -101,6 +101,10 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements try { HandlerCatchData take = taskQueue.poll(); Element rootElement = getRootElement(take.getEvt()); + if (rootElement == null) { + logger.error("处理NOTIFY消息时未获取到消息体,{}", take.getEvt().getRequest()); + continue; + } String cmd = XmlUtil.getText(rootElement, "CmdType"); if (CmdType.CATALOG.equals(cmd)) { @@ -142,6 +146,10 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements // 回复 200 OK Element rootElement = getRootElement(evt); + if (rootElement == null) { + logger.error("处理MobilePosition移动位置Notify时未获取到消息体,{}", evt.getRequest()); + return; + } MobilePosition mobilePosition = new MobilePosition(); mobilePosition.setCreateTime(DateUtil.getNow()); @@ -229,6 +237,10 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader); Element rootElement = getRootElement(evt); + if (rootElement == null) { + logger.error("处理alarm设备报警Notify时未获取到消息体{}", evt.getRequest()); + return; + } Element deviceIdElement = rootElement.element("DeviceID"); String channelId = deviceIdElement.getText().toString(); @@ -239,7 +251,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements } rootElement = getRootElement(evt, device.getCharset()); if (rootElement == null) { - logger.warn("[ NotifyAlarm ] content cannot be null"); + logger.warn("[ NotifyAlarm ] content cannot be null, {}", evt.getRequest()); return; } DeviceAlarm deviceAlarm = new DeviceAlarm(); @@ -338,7 +350,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements } Element rootElement = getRootElement(evt, device.getCharset()); if (rootElement == null) { - logger.warn("[ 收到目录订阅 ] content cannot be null"); + logger.warn("[ 收到目录订阅 ] content cannot be null, {}", evt.getRequest()); return; } Element deviceListElement = rootElement.element("DeviceList"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index d9d94797..13cc1b66 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -84,6 +84,10 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme Request request = evt.getRequest(); try { Element rootElement = getRootElement(evt); + if (rootElement == null) { + logger.error("处理SUBSCRIBE请求 未获取到消息体{}", evt.getRequest()); + return; + } String cmd = XmlUtil.getText(rootElement, "CmdType"); if (CmdType.MOBILE_POSITION.equals(cmd)) { processNotifyMobilePosition(evt, rootElement); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java index e004b89f..83571a0d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java @@ -108,6 +108,11 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement Element rootElement = null; try { rootElement = getRootElement(evt); + if (rootElement == null) { + logger.error("处理SUBSCRIBE请求 未获取到消息体{}", evt.getRequest()); + responseAck(evt, Response.BAD_REQUEST, "content is null"); + return; + } } catch (DocumentException e) { logger.warn("解析XML消息内容异常", e); // 不存在则回复404 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java index a061eb6a..56da4711 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java @@ -63,7 +63,7 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen try { rootElement = getRootElement(evt, device.getCharset()); if (rootElement == null) { - logger.warn("[ 移动设备位置数据通知 ] content cannot be null"); + logger.warn("[ 移动设备位置数据通知 ] content cannot be null, {}", evt.getRequest()); responseAck(evt, Response.BAD_REQUEST); return; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java index e7d8d341..be01fd70 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -96,7 +96,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp try { Element rootElement = getRootElement(take.getEvt(), take.getDevice().getCharset()); if (rootElement == null) { - logger.warn("[ 收到通道 ] content cannot be null"); + logger.warn("[ 收到通道 ] content cannot be null, {}", evt.getRequest()); continue; } Element deviceListElement = rootElement.element("DeviceList"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java index c6d029f7..78ba61a9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java @@ -76,7 +76,7 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent try { rootElement = getRootElement(evt, device.getCharset()); if (rootElement == null) { - logger.warn("[ 接收到DeviceInfo应答消息 ] content cannot be null"); + logger.warn("[ 接收到DeviceInfo应答消息 ] content cannot be null, {}", evt.getRequest()); responseAck(evt, Response.BAD_REQUEST); return; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java index 9923f7c2..b6643e38 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java @@ -66,7 +66,7 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar try { rootElement = getRootElement(evt, device.getCharset()); if (rootElement == null) { - logger.warn("[ 移动设备位置数据查询回复 ] content cannot be null"); + logger.warn("[ 移动设备位置数据查询回复 ] content cannot be null, {}", evt.getRequest()); responseAck(evt, Response.BAD_REQUEST); return; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java index df4dccff..0ed119ee 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java @@ -53,7 +53,7 @@ public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent try { rootElement = getRootElement(evt, device.getCharset()); if (rootElement == null) { - logger.warn("[ 设备预置位查询应答 ] content cannot be null"); + logger.warn("[ 设备预置位查询应答 ] content cannot be null, {}", evt.getRequest()); responseAck(evt, Response.BAD_REQUEST); return; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java index 480ea738..20203ca5 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java @@ -81,7 +81,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent HandlerCatchData take = taskQueue.poll(); Element rootElementForCharset = getRootElement(take.getEvt(), take.getDevice().getCharset()); if (rootElement == null) { - logger.warn("[ 国标录像 ] content cannot be null"); + logger.warn("[ 国标录像 ] content cannot be null, {}", evt.getRequest()); continue; } String sn = getText(rootElementForCharset, "SN");