Skip to content

Commit

Permalink
Correctly propagate safety information for Multimap collectors (#2891)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoenig10 authored Sep 27, 2024
1 parent cf48eef commit 2d3f434
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,12 @@ public final class SafetyPropagationTransfer implements ForwardTransferFunction<
.onClass(Collectors.class.getName())
.namedAnyOf("toMap", "toUnmodifiableMap", "toConcurrentMap"),
MethodMatchers.staticMethod().onClass(ImmutableMap.class.getName()).named("toImmutableMap"),
MethodMatchers.staticMethod()
.onClass(ImmutableListMultimap.class.getName())
.namedAnyOf("toImmutableListMultimap", "flatteningToImmutableListMultimap"),
MethodMatchers.staticMethod()
.onClass(ImmutableSetMultimap.class.getName())
.namedAnyOf("toImmutableSetMultimap", "flatteningToImmutableSetMultimap"),
MethodMatchers.staticMethod()
.onClass(ImmutableBiMap.class.getName())
.named("toImmutableBiMap"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,14 @@ public void testTransformingStreamCollectors() {
" fun(stream.collect(Collectors.toConcurrentMap(TopLevel::name, TopLevel::value)));",
" fun(stream.collect(Collectors.toUnmodifiableMap(TopLevel::name, TopLevel::value)));",
" fun(stream.collect(ImmutableMap.toImmutableMap(TopLevel::name, TopLevel::value)));",
" fun(stream.collect(ImmutableListMultimap.toImmutableListMultimap(TopLevel::name,"
+ " TopLevel::value)));",
" fun(stream.collect(ImmutableListMultimap.flatteningToImmutableListMultimap(TopLevel::name,"
+ " v -> Stream.of(v.value()))));",
" fun(stream.collect(ImmutableSetMultimap.toImmutableSetMultimap(TopLevel::name,"
+ " TopLevel::value)));",
" fun(stream.collect(ImmutableSetMultimap.flatteningToImmutableSetMultimap(TopLevel::name,"
+ " v -> Stream.of(v.value()))));",
" fun(stream.collect(ImmutableBiMap.toImmutableBiMap(TopLevel::name, TopLevel::value)));",
" }",
" private static void fun(@Safe Object value) {}",
Expand Down
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-2891.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: fix
fix:
description: Eliminate false positives produces by `IllegalSafeLoggingArgument`
when using `Multimap` collectors.
links:
- https://github.com/palantir/gradle-baseline/pull/2891

0 comments on commit 2d3f434

Please sign in to comment.