Fix nullness warnings in testutil package
PiperOrigin-RevId: 327190676
This commit is contained in:
parent
99d245f7a6
commit
54c92080bf
@ -405,6 +405,21 @@ public final class Util {
|
||||
return concatenation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the contents of {@code list} into {@code array}.
|
||||
*
|
||||
* <p>{@code list.size()} must be the same as {@code array.length} to ensure the contents can be
|
||||
* copied into {@code array} without leaving any nulls at the end.
|
||||
*
|
||||
* @param list The list to copy items from.
|
||||
* @param array The array to copy items to.
|
||||
*/
|
||||
@SuppressWarnings("nullness:toArray.nullable.elements.not.newarray")
|
||||
public static <T> void nullSafeListToArray(List<T> list, T[] array) {
|
||||
Assertions.checkState(list.size() == array.length);
|
||||
list.toArray(array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Handler} on the current {@link Looper} thread.
|
||||
*
|
||||
|
@ -31,6 +31,7 @@ import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
|
||||
import com.google.android.exoplayer2.upstream.TransferListener;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.MimeTypes;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.compatqual.NullableType;
|
||||
@ -48,7 +49,7 @@ public class FakeAdaptiveMediaPeriod extends FakeMediaPeriod
|
||||
@Nullable private final TransferListener transferListener;
|
||||
private final long durationUs;
|
||||
|
||||
@MonotonicNonNull private Callback callback;
|
||||
private @MonotonicNonNull Callback callback;
|
||||
private ChunkSampleStream<FakeChunkSource>[] sampleStreams;
|
||||
private SequenceableLoader sequenceableLoader;
|
||||
|
||||
@ -99,7 +100,7 @@ public class FakeAdaptiveMediaPeriod extends FakeMediaPeriod
|
||||
}
|
||||
}
|
||||
sampleStreams = newSampleStreamArray(validStreams.size());
|
||||
validStreams.toArray(sampleStreams);
|
||||
Util.nullSafeListToArray(validStreams, sampleStreams);
|
||||
this.sequenceableLoader = new CompositeSequenceableLoader(sampleStreams);
|
||||
return returnPositionUs;
|
||||
}
|
||||
|
@ -217,8 +217,7 @@ public class FakeDataSource extends BaseDataSource {
|
||||
* this method.
|
||||
*/
|
||||
public final DataSpec[] getAndClearOpenedDataSpecs() {
|
||||
DataSpec[] dataSpecs = new DataSpec[openedDataSpecs.size()];
|
||||
openedDataSpecs.toArray(dataSpecs);
|
||||
DataSpec[] dataSpecs = openedDataSpecs.toArray(new DataSpec[0]);
|
||||
openedDataSpecs.clear();
|
||||
return dataSpecs;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user