Source:
<code>protected void onEntryPublished(String entryId, LiveEntryCache liveEntryCache, final KalturaMediaServerIndex serverIndex, String applicationName) { logger.debug("onEntryPublished - entryId: " + entryId); if (liveEntryCache == null || liveEntryCache.getLiveEntry() == null) { logger.debug("liveEntryCache is null. or getLiveEntry is null"); return; } <START> synchronized (liveEntryCache.getLiveEntryCacheLock()) { <END> KalturaLiveEntry liveEntry = liveEntryCache.getLiveEntry(); logger.debug("currentBroadcastStartTime = " + liveEntry.currentBroadcastStartTime); if (liveEntry.currentBroadcastStartTime > 0d) { logger.debug("currentBroadcastStartTime is updated"); return; } KalturaClient impersonateClient = impersonate(liveEntry.partnerId); try { KalturaLiveStreamEntry updatedEntry = impersonateClient.getLiveStreamService().get(entryId); logger.debug("got updatedEntry from the server. currentBroadcastStartTime = " + updatedEntry.currentBroadcastStartTime); if (updatedEntry.currentBroadcastStartTime > 0d) { logger.debug("currentBroadcastStartTime already set in server - updating liveEntryCache"); liveEntry.currentBroadcastStartTime = updatedEntry.currentBroadcastStartTime; return; } liveEntry.currentBroadcastStartTime = new Date().getTime(); logger.debug("currentBroadcastStartTime is not updated in server. updating to value - " + liveEntry.currentBroadcastStartTime); boolean isPrimary = KalturaMediaServerIndex.PRIMARY.equals(serverIndex); if (isPrimary) { KalturaLiveEntry updatedLiveEntry = liveEntry.getClass().newInstance(); updatedLiveEntry.currentBroadcastStartTime = liveEntry.currentBroadcastStartTime; impersonateClient.getLiveStreamService().update(liveEntry.id, (KalturaLiveStreamEntry) updatedLiveEntry); logger.debug("server updated with currentBroadcastStartTime = " + updatedLiveEntry.currentBroadcastStartTime); } else { logger.debug("current Wowza is not primary. skipping server update."); } } catch (KalturaApiException e) { logger.error("failed to update entry [" + liveEntry.id + "]",e); } catch (InstantiationException | IllegalAccessException e) { logger.error("failed to instantiate updatedLiveEntry", e); } } }</code><technical_language>Lock liveEntryCache discussed</technical_language>

Target:
protected void onEntryPublished(String entryId, LiveEntryCache liveEntryCache, final KalturaMediaServerIndex serverIndex, String applicationName) { if (liveEntryCache == null || liveEntryCache.getLiveEntry() == null) { logger.debug("liveEntryCache is null. or getLiveEntry is null"); return; } synchronized (liveEntryCache) { logger.debug("onEntryPublished - entryId: " + entryId); KalturaLiveEntry liveEntry = liveEntryCache.getLiveEntry(); logger.debug("currentBroadcastStartTime = " + liveEntry.currentBroadcastStartTime); if (liveEntry.currentBroadcastStartTime > 0d) { return; } KalturaClient impersonateClient = impersonate(liveEntry.partnerId); try { KalturaLiveStreamEntry updatedEntry = impersonateClient.getLiveStreamService().get(entryId); logger.debug("got updatedEntry from the server. currentBroadcastStartTime = " + updatedEntry.currentBroadcastStartTime); if (updatedEntry.currentBroadcastStartTime > 0d) { logger.debug("currentBroadcastStartTime already set in server - updating liveEntryCache: " + liveEntry.currentBroadcastStartTime); updateEntryCache(updatedEntry); return; } liveEntry.currentBroadcastStartTime = new Date().getTime() / 1000.0; logger.debug("currentBroadcastStartTime is not updated in server. updating to value - " + liveEntry.currentBroadcastStartTime); boolean isPrimary = KalturaMediaServerIndex.PRIMARY.equals(serverIndex); if (isPrimary) { KalturaLiveEntry updatedLiveEntry = liveEntry.getClass().newInstance(); updatedLiveEntry.currentBroadcastStartTime = liveEntry.currentBroadcastStartTime; impersonateClient.getLiveStreamService().update(liveEntry.id, (KalturaLiveStreamEntry) updatedLiveEntry); logger.debug("server updated with currentBroadcastStartTime = " + updatedLiveEntry.currentBroadcastStartTime); } else { logger.debug("current Wowza is not primary. skipping server update."); } } catch (KalturaApiException e) { logger.error("failed to update entry [" + liveEntry.id + "]", e); } catch (InstantiationException | IllegalAccessException e) { logger.error("failed to instantiate updatedLiveEntry", e); } } }