diff --git a/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java b/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java index e066448e4c86..a364502d2e4e 100644 --- a/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java +++ b/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java @@ -17,6 +17,7 @@ import static java.lang.Double.longBitsToDouble; import com.google.common.annotations.GwtIncompatible; +import com.google.common.primitives.ImmutableLongArray; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.concurrent.atomic.AtomicLongArray; @@ -247,13 +248,11 @@ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); - // Read in array length and allocate array int length = s.readInt(); - this.longs = new AtomicLongArray(length); - - // Read in all elements in the proper order. + ImmutableLongArray.Builder builder = ImmutableLongArray.builder(); for (int i = 0; i < length; i++) { - set(i, s.readDouble()); + builder.add(doubleToRawLongBits(s.readDouble())); } + this.longs = new AtomicLongArray(builder.build().toArray()); } } diff --git a/guava-gwt/src/com/google/common/collect/CompoundOrdering_CustomFieldSerializer.java b/guava-gwt/src/com/google/common/collect/CompoundOrdering_CustomFieldSerializer.java index 33b60f201ed1..527c2656100a 100644 --- a/guava-gwt/src/com/google/common/collect/CompoundOrdering_CustomFieldSerializer.java +++ b/guava-gwt/src/com/google/common/collect/CompoundOrdering_CustomFieldSerializer.java @@ -36,7 +36,7 @@ public static void deserialize(SerializationStreamReader reader, CompoundOrderin public static CompoundOrdering instantiate(SerializationStreamReader reader) throws SerializationException { int n = reader.readInt(); - List> comparators = new ArrayList<>(n); + List> comparators = new ArrayList<>(); for (int i = 0; i < n; i++) { comparators.add((Comparator) reader.readObject()); } diff --git a/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java b/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java index e066448e4c86..a364502d2e4e 100644 --- a/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java +++ b/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java @@ -17,6 +17,7 @@ import static java.lang.Double.longBitsToDouble; import com.google.common.annotations.GwtIncompatible; +import com.google.common.primitives.ImmutableLongArray; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.concurrent.atomic.AtomicLongArray; @@ -247,13 +248,11 @@ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); - // Read in array length and allocate array int length = s.readInt(); - this.longs = new AtomicLongArray(length); - - // Read in all elements in the proper order. + ImmutableLongArray.Builder builder = ImmutableLongArray.builder(); for (int i = 0; i < length; i++) { - set(i, s.readDouble()); + builder.add(doubleToRawLongBits(s.readDouble())); } + this.longs = new AtomicLongArray(builder.build().toArray()); } }