From 6968839f21fb05bf6e3204c2040ee47130006cd0 Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: 星期日, 27 十二月 2020 08:19:34 +0800 Subject: [PATCH] 修复空指针异常 --- src/main/java/com/genersoft/iot/vmp/gb28181/session/SsrcUtil.java | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/SsrcUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/SsrcUtil.java index b0fb561..d6b75f8 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/SsrcUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/SsrcUtil.java @@ -70,14 +70,16 @@ */ private static String getSN() { String sn = null; + int index = 0; if (notUsed.size() == 0) { throw new RuntimeException("ssrc宸茬粡鐢ㄥ畬"); } else if (notUsed.size() == 1) { sn = notUsed.get(0); } else { - sn = notUsed.get(new Random().nextInt(notUsed.size() - 1)); + index = new Random().nextInt(notUsed.size() - 1); + sn = notUsed.get(index); } - notUsed.remove(0); + notUsed.remove(index); isUsed.add(sn); return sn; } -- Gitblit v1.8.0