Merge pull request #1760 from QianNangong/patch-3

修复一个可能触发 NPE 的问题
pull/1769/head
648540858 2025-01-27 07:39:35 +08:00 committed by GitHub
commit c9ded07e31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -10,6 +10,8 @@ import lombok.Data;
import java.util.List;
import java.util.Map;
import org.springframework.util.ObjectUtils;
/**
*
*/
@ -82,6 +84,8 @@ public class MediaInfo {
Long bytesSpeed = jsonObject.getLong("bytesSpeed");
if (totalReaderCount != null) {
mediaInfo.setReaderCount(totalReaderCount);
} else {
mediaInfo.setReaderCount(0);
}
if (online != null) {
mediaInfo.setOnline(online);
@ -106,7 +110,7 @@ public class MediaInfo {
}
}
JSONArray jsonArray = jsonObject.getJSONArray("tracks");
if (!jsonArray.isEmpty()) {
if (!ObjectUtils.isEmpty(jsonArray)) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject trackJson = jsonArray.getJSONObject(i);
Integer channels = trackJson.getInteger("channels");