Only copy roomInfo if its valid and null check safety! (#146)

This commit is contained in:
David Kohler
2025-09-17 18:55:10 -04:00
committed by GitHub
parent aa1ef1f170
commit 57ff1f1385
2 changed files with 3 additions and 1 deletions

View File

@@ -124,7 +124,6 @@ public class TikTokLiveClient implements LiveClient
tikTokEventHandler.publish(this, new TikTokConnectingEvent());
var userDataRequest = new LiveUserData.Request(roomInfo.getHostName());
var userData = httpClient.fetchLiveUserData(userDataRequest);
roomInfo.copy(userData.getRoomInfo());
if (userData.getUserStatus() == LiveUserData.UserStatus.Offline)
throw new TikTokLiveOfflineHostException("User is offline: " + roomInfo.getHostName(), userData, null);
@@ -132,6 +131,8 @@ public class TikTokLiveClient implements LiveClient
if (userData.getUserStatus() == LiveUserData.UserStatus.NotFound)
throw new TikTokLiveUnknownHostException("User not found: " + roomInfo.getHostName(), userData, null);
roomInfo.copy(userData.getRoomInfo());
var liveDataRequest = new LiveData.Request(userData.getRoomInfo().getRoomId());
var liveData = httpClient.fetchLiveData(liveDataRequest);

View File

@@ -58,6 +58,7 @@ public class TikTokRoomInfo implements LiveRoomInfo
@Override
public void copy(LiveRoomInfo roomInfo) {
if (roomInfo == null) return;
this.roomId = roomInfo.getRoomId();
this.likesCount = roomInfo.getLikesCount();
this.viewersCount = roomInfo.getViewersCount();