Skip to content

Commit

Permalink
Handle duplicate keys in map #10734
Browse files Browse the repository at this point in the history
  • Loading branch information
anatol-sialitski authored and rymsha committed Nov 1, 2024
1 parent 689b9f7 commit 872906a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ private Map<String, ImageStyle> getImageStyleMap( final StyleDescriptors styleDe
return styleDescriptors.stream()
.flatMap( styleDescriptor -> styleDescriptor.getElements().stream() )
.filter( elementStyle -> ImageStyle.STYLE_ELEMENT_NAME.equals( elementStyle.getElement() ) )
.collect( Collectors.toUnmodifiableMap( ElementStyle::getName, elementStyle -> (ImageStyle) elementStyle ) );
.collect( Collectors.toUnmodifiableMap( ElementStyle::getName, elementStyle -> (ImageStyle) elementStyle,
( existingKey, newKey ) -> existingKey ) );
}

private StyleDescriptors getStyleDescriptors( final PortalRequest portalRequest )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,16 @@ public void process_image_with_styles()
aspectRatio( "2:1" ).
filter( "myfilter" ).
build();
final StyleDescriptor styleDescriptor = StyleDescriptor.create().
application( ApplicationKey.from( "myapp" ) ).
final StyleDescriptor styleDescriptor1 = StyleDescriptor.create().
application( ApplicationKey.from( "myapp1" ) ).
addStyleElement( imageStyle ).
build();
when( styleDescriptorService.getByApplications( Mockito.any() ) ).
thenReturn( StyleDescriptors.from( styleDescriptor ) );
final StyleDescriptor styleDescriptor2 = StyleDescriptor.create().
application( ApplicationKey.from( "myapp2" ) ).
addStyleElement( imageStyle ).
build();
when( styleDescriptorService.getByApplications( Mockito.any() ) ).thenReturn(
StyleDescriptors.from( styleDescriptor1, styleDescriptor2 ) );

final Map<String, String> imageProjection = new HashMap<>();

Expand Down

0 comments on commit 872906a

Please sign in to comment.