diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyService.java b/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyService.java index b37cc6ce35..4ddcfa1c91 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyService.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyService.java @@ -286,20 +286,20 @@ void mapMojitoAndThirdPartyTextUnits( logger.debug("Batch the third party text units by asset"); LoadingCache> assetCache = getAssetCache(repository); + Map> thirdPartyTextUnitsByAsset = thirdPartyTextUnits.stream() + .filter(o -> assetCache.getUnchecked(o.getAssetPath()).isPresent()) .collect( groupingBy( - o -> assetCache.getUnchecked(o.getAssetPath()).orElse(null), + o -> assetCache.getUnchecked(o.getAssetPath()).get(), LinkedHashMap::new, toList())); - logger.debug( - "Perform mapping by asset (exclude null asset, that could appear if asset path didn't match)"); - thirdPartyTextUnitsByAsset.entrySet().stream() - .filter(e -> e.getKey() != null) - .forEach( - e -> mapThirdPartyTextUnitsToTextUnitDTOs(e.getKey(), e.getValue(), pluralSeparator)); + logger.debug("Perform mapping by asset"); + thirdPartyTextUnitsByAsset.forEach( + (asset, textUnits) -> + mapThirdPartyTextUnitsToTextUnitDTOs(asset, textUnits, pluralSeparator)); } @Pollable(message = "Push AI translations to third party service.")