Commit 874b37ef35104fa8067e869ddf5458053146b519

Authored by 648540858
1 parent bab5a5ab

修复级联注册消息回复的空指针异常

src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
... ... @@ -6,6 +6,8 @@ import org.springframework.scheduling.annotation.Scheduled;
6 6 import org.springframework.stereotype.Component;
7 7  
8 8 import javax.sip.*;
  9 +import javax.sip.header.CallIdHeader;
  10 +import javax.sip.message.Response;
9 11 import java.util.Calendar;
10 12 import java.util.Date;
11 13 import java.util.Map;
... ... @@ -23,6 +25,7 @@ public class SipSubscribe {
23 25 private Map<String, Date> timeSubscribes = new ConcurrentHashMap<>();
24 26  
25 27 // @Scheduled(cron="*/5 * * * * ?") //每五秒执行一次
  28 +// @Scheduled(fixedRate= 100 * 60 * 60 )
26 29 @Scheduled(cron="0 0 * * * ?") //每小时执行一次, 每个整点
27 30 public void execute(){
28 31 logger.info("[定时任务] 清理过期的订阅信息");
... ... @@ -58,11 +61,15 @@ public class SipSubscribe {
58 61 this.event = event;
59 62 if (event instanceof ResponseEvent) {
60 63 ResponseEvent responseEvent = (ResponseEvent)event;
61   - this.type = "response";
62   - this.msg = responseEvent.getResponse().getReasonPhrase();
63   - this.statusCode = responseEvent.getResponse().getStatusCode();
64   - this.callId = responseEvent.getDialog().getCallId().getCallId();
65   - this.dialog = responseEvent.getDialog();
  64 + Response response = responseEvent.getResponse();
  65 + this.dialog = responseEvent.getDialog();
  66 + this.type = "response";
  67 + if (response != null) {
  68 + this.msg = response.getReasonPhrase();
  69 + this.statusCode = response.getStatusCode();
  70 + }
  71 + this.callId = ((CallIdHeader)response.getHeader(CallIdHeader.NAME)).getCallId();
  72 +
66 73 }else if (event instanceof TimeoutEvent) {
67 74 TimeoutEvent timeoutEvent = (TimeoutEvent)event;
68 75 this.type = "timeout";
... ...