Skip to content

Commit 7d7cc7d

Browse files
cpovirkGoogle Java Core Libraries
authored and
Google Java Core Libraries
committed
Address a couple nullness errors.
One is from cl/725859649 (I _thought_ I had tested that change with nullness checking on), and the other is from [a change to the annotations for `Map.replace` used by Android](jspecify/jdk#118). (I think that the latter change should actually be leading to _more_ errors in our _other_ implementations of the 3-arg `Map.replace`, like in `Maps` and `Synchronized`. The lack of errors is probably a bug in the checker.) RELNOTES=n/a PiperOrigin-RevId: 728229469
1 parent 46ce527 commit 7d7cc7d

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

android/guava/src/com/google/common/collect/ForwardingConcurrentMap.java

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public boolean remove(@Nullable Object key, @Nullable Object value) {
6666

6767
@CanIgnoreReturnValue
6868
@Override
69+
@SuppressWarnings("nullness") // https://github.com/jspecify/jdk/issues/118
6970
public boolean replace(K key, V oldValue, V newValue) {
7071
return delegate().replace(key, oldValue, newValue);
7172
}

android/guava/src/com/google/common/collect/TreeBasedTable.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ public static <R, C, V> TreeBasedTable<R, C, V> create(
121121
*/
122122
public static <R, C, V> TreeBasedTable<R, C, V> create(TreeBasedTable<R, C, ? extends V> table) {
123123
TreeBasedTable<R, C, V> result =
124-
new TreeBasedTable<>(table.rowKeySet().comparator(), table.columnComparator());
124+
// requireNonNull is safe, as discussed in rowComparator() below.
125+
new TreeBasedTable<>(
126+
requireNonNull(table.rowKeySet().comparator()), table.columnComparator());
125127
result.putAll(table);
126128
return result;
127129
}

guava/src/com/google/common/collect/ForwardingConcurrentMap.java

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public boolean remove(@Nullable Object key, @Nullable Object value) {
6666

6767
@CanIgnoreReturnValue
6868
@Override
69+
@SuppressWarnings("nullness") // https://github.com/jspecify/jdk/issues/118
6970
public boolean replace(K key, V oldValue, V newValue) {
7071
return delegate().replace(key, oldValue, newValue);
7172
}

guava/src/com/google/common/collect/TreeBasedTable.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ public static <R, C, V> TreeBasedTable<R, C, V> create(
121121
*/
122122
public static <R, C, V> TreeBasedTable<R, C, V> create(TreeBasedTable<R, C, ? extends V> table) {
123123
TreeBasedTable<R, C, V> result =
124-
new TreeBasedTable<>(table.rowKeySet().comparator(), table.columnComparator());
124+
// requireNonNull is safe, as discussed in rowComparator() below.
125+
new TreeBasedTable<>(
126+
requireNonNull(table.rowKeySet().comparator()), table.columnComparator());
125127
result.putAll(table);
126128
return result;
127129
}

0 commit comments

Comments
 (0)