处理获取消息体内容为空时造成的空指针异常
This commit is contained in:
parent
46317f896b
commit
03c0232804
@ -101,6 +101,10 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
|||||||
try {
|
try {
|
||||||
HandlerCatchData take = taskQueue.poll();
|
HandlerCatchData take = taskQueue.poll();
|
||||||
Element rootElement = getRootElement(take.getEvt());
|
Element rootElement = getRootElement(take.getEvt());
|
||||||
|
if (rootElement == null) {
|
||||||
|
logger.error("处理NOTIFY消息时未获取到消息体,{}", take.getEvt().getRequest());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
String cmd = XmlUtil.getText(rootElement, "CmdType");
|
String cmd = XmlUtil.getText(rootElement, "CmdType");
|
||||||
|
|
||||||
if (CmdType.CATALOG.equals(cmd)) {
|
if (CmdType.CATALOG.equals(cmd)) {
|
||||||
@ -142,6 +146,10 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
|||||||
|
|
||||||
// 回复 200 OK
|
// 回复 200 OK
|
||||||
Element rootElement = getRootElement(evt);
|
Element rootElement = getRootElement(evt);
|
||||||
|
if (rootElement == null) {
|
||||||
|
logger.error("处理MobilePosition移动位置Notify时未获取到消息体,{}", evt.getRequest());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MobilePosition mobilePosition = new MobilePosition();
|
MobilePosition mobilePosition = new MobilePosition();
|
||||||
mobilePosition.setCreateTime(DateUtil.getNow());
|
mobilePosition.setCreateTime(DateUtil.getNow());
|
||||||
@ -229,6 +237,10 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
|||||||
String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader);
|
String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader);
|
||||||
|
|
||||||
Element rootElement = getRootElement(evt);
|
Element rootElement = getRootElement(evt);
|
||||||
|
if (rootElement == null) {
|
||||||
|
logger.error("处理alarm设备报警Notify时未获取到消息体{}", evt.getRequest());
|
||||||
|
return;
|
||||||
|
}
|
||||||
Element deviceIdElement = rootElement.element("DeviceID");
|
Element deviceIdElement = rootElement.element("DeviceID");
|
||||||
String channelId = deviceIdElement.getText().toString();
|
String channelId = deviceIdElement.getText().toString();
|
||||||
|
|
||||||
@ -239,7 +251,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
|||||||
}
|
}
|
||||||
rootElement = getRootElement(evt, device.getCharset());
|
rootElement = getRootElement(evt, device.getCharset());
|
||||||
if (rootElement == null) {
|
if (rootElement == null) {
|
||||||
logger.warn("[ NotifyAlarm ] content cannot be null");
|
logger.warn("[ NotifyAlarm ] content cannot be null, {}", evt.getRequest());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DeviceAlarm deviceAlarm = new DeviceAlarm();
|
DeviceAlarm deviceAlarm = new DeviceAlarm();
|
||||||
@ -338,7 +350,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
|||||||
}
|
}
|
||||||
Element rootElement = getRootElement(evt, device.getCharset());
|
Element rootElement = getRootElement(evt, device.getCharset());
|
||||||
if (rootElement == null) {
|
if (rootElement == null) {
|
||||||
logger.warn("[ 收到目录订阅 ] content cannot be null");
|
logger.warn("[ 收到目录订阅 ] content cannot be null, {}", evt.getRequest());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Element deviceListElement = rootElement.element("DeviceList");
|
Element deviceListElement = rootElement.element("DeviceList");
|
||||||
|
@ -84,6 +84,10 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
|
|||||||
Request request = evt.getRequest();
|
Request request = evt.getRequest();
|
||||||
try {
|
try {
|
||||||
Element rootElement = getRootElement(evt);
|
Element rootElement = getRootElement(evt);
|
||||||
|
if (rootElement == null) {
|
||||||
|
logger.error("处理SUBSCRIBE请求 未获取到消息体{}", evt.getRequest());
|
||||||
|
return;
|
||||||
|
}
|
||||||
String cmd = XmlUtil.getText(rootElement, "CmdType");
|
String cmd = XmlUtil.getText(rootElement, "CmdType");
|
||||||
if (CmdType.MOBILE_POSITION.equals(cmd)) {
|
if (CmdType.MOBILE_POSITION.equals(cmd)) {
|
||||||
processNotifyMobilePosition(evt, rootElement);
|
processNotifyMobilePosition(evt, rootElement);
|
||||||
|
@ -108,6 +108,11 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
|
|||||||
Element rootElement = null;
|
Element rootElement = null;
|
||||||
try {
|
try {
|
||||||
rootElement = getRootElement(evt);
|
rootElement = getRootElement(evt);
|
||||||
|
if (rootElement == null) {
|
||||||
|
logger.error("处理SUBSCRIBE请求 未获取到消息体{}", evt.getRequest());
|
||||||
|
responseAck(evt, Response.BAD_REQUEST, "content is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
} catch (DocumentException e) {
|
} catch (DocumentException e) {
|
||||||
logger.warn("解析XML消息内容异常", e);
|
logger.warn("解析XML消息内容异常", e);
|
||||||
// 不存在则回复404
|
// 不存在则回复404
|
||||||
|
@ -63,7 +63,7 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
|
|||||||
try {
|
try {
|
||||||
rootElement = getRootElement(evt, device.getCharset());
|
rootElement = getRootElement(evt, device.getCharset());
|
||||||
if (rootElement == null) {
|
if (rootElement == null) {
|
||||||
logger.warn("[ 移动设备位置数据通知 ] content cannot be null");
|
logger.warn("[ 移动设备位置数据通知 ] content cannot be null, {}", evt.getRequest());
|
||||||
responseAck(evt, Response.BAD_REQUEST);
|
responseAck(evt, Response.BAD_REQUEST);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
|||||||
try {
|
try {
|
||||||
Element rootElement = getRootElement(take.getEvt(), take.getDevice().getCharset());
|
Element rootElement = getRootElement(take.getEvt(), take.getDevice().getCharset());
|
||||||
if (rootElement == null) {
|
if (rootElement == null) {
|
||||||
logger.warn("[ 收到通道 ] content cannot be null");
|
logger.warn("[ 收到通道 ] content cannot be null, {}", evt.getRequest());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Element deviceListElement = rootElement.element("DeviceList");
|
Element deviceListElement = rootElement.element("DeviceList");
|
||||||
|
@ -76,7 +76,7 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
|
|||||||
try {
|
try {
|
||||||
rootElement = getRootElement(evt, device.getCharset());
|
rootElement = getRootElement(evt, device.getCharset());
|
||||||
if (rootElement == null) {
|
if (rootElement == null) {
|
||||||
logger.warn("[ 接收到DeviceInfo应答消息 ] content cannot be null");
|
logger.warn("[ 接收到DeviceInfo应答消息 ] content cannot be null, {}", evt.getRequest());
|
||||||
responseAck(evt, Response.BAD_REQUEST);
|
responseAck(evt, Response.BAD_REQUEST);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
|
|||||||
try {
|
try {
|
||||||
rootElement = getRootElement(evt, device.getCharset());
|
rootElement = getRootElement(evt, device.getCharset());
|
||||||
if (rootElement == null) {
|
if (rootElement == null) {
|
||||||
logger.warn("[ 移动设备位置数据查询回复 ] content cannot be null");
|
logger.warn("[ 移动设备位置数据查询回复 ] content cannot be null, {}", evt.getRequest());
|
||||||
responseAck(evt, Response.BAD_REQUEST);
|
responseAck(evt, Response.BAD_REQUEST);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent
|
|||||||
try {
|
try {
|
||||||
rootElement = getRootElement(evt, device.getCharset());
|
rootElement = getRootElement(evt, device.getCharset());
|
||||||
if (rootElement == null) {
|
if (rootElement == null) {
|
||||||
logger.warn("[ 设备预置位查询应答 ] content cannot be null");
|
logger.warn("[ 设备预置位查询应答 ] content cannot be null, {}", evt.getRequest());
|
||||||
responseAck(evt, Response.BAD_REQUEST);
|
responseAck(evt, Response.BAD_REQUEST);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent
|
|||||||
HandlerCatchData take = taskQueue.poll();
|
HandlerCatchData take = taskQueue.poll();
|
||||||
Element rootElementForCharset = getRootElement(take.getEvt(), take.getDevice().getCharset());
|
Element rootElementForCharset = getRootElement(take.getEvt(), take.getDevice().getCharset());
|
||||||
if (rootElement == null) {
|
if (rootElement == null) {
|
||||||
logger.warn("[ 国标录像 ] content cannot be null");
|
logger.warn("[ 国标录像 ] content cannot be null, {}", evt.getRequest());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String sn = getText(rootElementForCharset, "SN");
|
String sn = getText(rootElementForCharset, "SN");
|
||||||
|
Loading…
Reference in New Issue
Block a user