Skip to content

Commit

Permalink
Fix null asset mapping on text unit mapping that would throw exceptio…
Browse files Browse the repository at this point in the history
…n before filtering (#188)
  • Loading branch information
mattwilshire authored Nov 8, 2024
1 parent 830f9a9 commit 8b9fb5a
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,20 +286,20 @@ void mapMojitoAndThirdPartyTextUnits(

logger.debug("Batch the third party text units by asset");
LoadingCache<String, Optional<Asset>> assetCache = getAssetCache(repository);

Map<Asset, List<ThirdPartyTextUnit>> 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.")
Expand Down

0 comments on commit 8b9fb5a

Please sign in to comment.