Skip to content

Commit

Permalink
Fix/suppress more warnings.
Browse files Browse the repository at this point in the history
For the mutex change, compare cl/660005124.

Also, sneak in an implementation comment that would have been better in cl/704698587.

RELNOTES=n/a
PiperOrigin-RevId: 704748981
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Dec 10, 2024
1 parent 54cc5ea commit 983c106
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public static TestSuite suite() {
suite.addTest(
NavigableMapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
private final Object mutex = new Integer(1);
private final Object mutex = new Object[0]; // something Serializable

@Override
protected SortedMap<String, String> create(Entry<String, String>[] entries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ public void testLog2NaNInfinity() {
}

@GwtIncompatible // StrictMath
@SuppressWarnings("strictfp") // Guava still supports Java 8
private strictfp double trueLog2(double d) {
double trueLog2 = StrictMath.log(d) / StrictMath.log(2);
// increment until it's >= the true value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public static TestSuite suite() {
suite.addTest(
NavigableMapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
private final Object mutex = new Integer(1);
private final Object mutex = new Object[0]; // something Serializable

@Override
protected SortedMap<String, String> create(Entry<String, String>[] entries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ public void testLog2NaNInfinity() {
}

@GwtIncompatible // StrictMath
@SuppressWarnings("strictfp") // Guava still supports Java 8
private strictfp double trueLog2(double d) {
double trueLog2 = StrictMath.log(d) / StrictMath.log(2);
// increment until it's >= the true value
Expand Down
8 changes: 8 additions & 0 deletions guava/src/com/google/common/base/Joiner.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,18 @@ public String join(Iterable<? extends @Nullable Object> parts) {
int i = 0;
for (Object part : parts) {
if (i == toJoin.length) {
/*
* We first initialized toJoin to the size of the input collection. However, that size can
* go out of date (for a collection like CopyOnWriteArrayList, which may have been safely
* modified concurrently), or it might have been only an estimate to begin with (for a
* collection like ConcurrentHashMap, which sums up several counters that may not be in
* sync with one another). We accommodate that by resizing as necessary.
*/
toJoin = Arrays.copyOf(toJoin, expandedCapacity(toJoin.length, toJoin.length + 1));
}
toJoin[i++] = toString(part);
}
// We might not have seen the expected number of elements, as discussed above.
if (i != toJoin.length) {
toJoin = Arrays.copyOf(toJoin, i);
}
Expand Down

0 comments on commit 983c106

Please sign in to comment.