From 4199650c20e48cd3cb897a413aec13fa518c81cd Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 12 五月 2022 18:15:35 +0800
Subject: [PATCH] #471

---
 src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
index 97360d2..75b9f59 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
@@ -30,7 +30,7 @@
         CatalogData catalogData = data.get(device.getDeviceId());
         if (catalogData == null || catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) {
             catalogData = new CatalogData();
-            catalogData.setChannelList(new ArrayList<>());
+            catalogData.setChannelList(Collections.synchronizedList(new ArrayList<>()));
             catalogData.setDevice(device);
             catalogData.setSn(sn);
             catalogData.setStatus(CatalogData.CatalogDataStatus.ready);
@@ -46,7 +46,7 @@
             catalogData.setSn(sn);
             catalogData.setTotal(total);
             catalogData.setDevice(device);
-            catalogData.setChannelList(new ArrayList<>());
+            catalogData.setChannelList(Collections.synchronizedList(new ArrayList<>()));
             catalogData.setStatus(CatalogData.CatalogDataStatus.runIng);
             catalogData.setLastTime(new Date(System.currentTimeMillis()));
             data.put(deviceId, catalogData);
@@ -65,19 +65,25 @@
 
     public List<DeviceChannel> get(String deviceId) {
         CatalogData catalogData = data.get(deviceId);
-        if (catalogData == null) return null;
+        if (catalogData == null) {
+            return null;
+        }
         return catalogData.getChannelList();
     }
 
     public int getTotal(String deviceId) {
         CatalogData catalogData = data.get(deviceId);
-        if (catalogData == null) return 0;
+        if (catalogData == null) {
+            return 0;
+        }
         return catalogData.getTotal();
     }
 
     public SyncStatus getSyncStatus(String deviceId) {
         CatalogData catalogData = data.get(deviceId);
-        if (catalogData == null) return null;
+        if (catalogData == null) {
+            return null;
+        }
         SyncStatus syncStatus = new SyncStatus();
         syncStatus.setCurrent(catalogData.getChannelList().size());
         syncStatus.setTotal(catalogData.getTotal());
@@ -87,7 +93,9 @@
 
     public boolean isSyncRunning(String deviceId) {
         CatalogData catalogData = data.get(deviceId);
-        if (catalogData == null) return false;
+        if (catalogData == null) {
+            return false;
+        }
         return !catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end);
     }
 
@@ -125,7 +133,9 @@
 
     public void setChannelSyncEnd(String deviceId, String errorMsg) {
         CatalogData catalogData = data.get(deviceId);
-        if (catalogData == null)return;
+        if (catalogData == null) {
+            return;
+        }
         catalogData.setStatus(CatalogData.CatalogDataStatus.end);
         catalogData.setErrorMsg(errorMsg);
     }

--
Gitblit v1.8.0