Commit 32035e1b by andrewlewis Committed by Oliver Woodman

Fix NPE in ExtractorMediaPeriod

Also turn on nullity checks for ExtractorMediaPeriod.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=208467644
parent 1c09af02
...@@ -123,7 +123,7 @@ public final class MimeTypes { ...@@ -123,7 +123,7 @@ public final class MimeTypes {
* @param mimeType The mimeType to test. * @param mimeType The mimeType to test.
* @return Whether the top level type is audio. * @return Whether the top level type is audio.
*/ */
public static boolean isAudio(String mimeType) { public static boolean isAudio(@Nullable String mimeType) {
return BASE_TYPE_AUDIO.equals(getTopLevelType(mimeType)); return BASE_TYPE_AUDIO.equals(getTopLevelType(mimeType));
} }
...@@ -133,7 +133,7 @@ public final class MimeTypes { ...@@ -133,7 +133,7 @@ public final class MimeTypes {
* @param mimeType The mimeType to test. * @param mimeType The mimeType to test.
* @return Whether the top level type is video. * @return Whether the top level type is video.
*/ */
public static boolean isVideo(String mimeType) { public static boolean isVideo(@Nullable String mimeType) {
return BASE_TYPE_VIDEO.equals(getTopLevelType(mimeType)); return BASE_TYPE_VIDEO.equals(getTopLevelType(mimeType));
} }
...@@ -143,7 +143,7 @@ public final class MimeTypes { ...@@ -143,7 +143,7 @@ public final class MimeTypes {
* @param mimeType The mimeType to test. * @param mimeType The mimeType to test.
* @return Whether the top level type is text. * @return Whether the top level type is text.
*/ */
public static boolean isText(String mimeType) { public static boolean isText(@Nullable String mimeType) {
return BASE_TYPE_TEXT.equals(getTopLevelType(mimeType)); return BASE_TYPE_TEXT.equals(getTopLevelType(mimeType));
} }
...@@ -153,7 +153,7 @@ public final class MimeTypes { ...@@ -153,7 +153,7 @@ public final class MimeTypes {
* @param mimeType The mimeType to test. * @param mimeType The mimeType to test.
* @return Whether the top level type is application. * @return Whether the top level type is application.
*/ */
public static boolean isApplication(String mimeType) { public static boolean isApplication(@Nullable String mimeType) {
return BASE_TYPE_APPLICATION.equals(getTopLevelType(mimeType)); return BASE_TYPE_APPLICATION.equals(getTopLevelType(mimeType));
} }
......
...@@ -73,6 +73,7 @@ import java.util.regex.Pattern; ...@@ -73,6 +73,7 @@ import java.util.regex.Pattern;
import java.util.zip.DataFormatException; import java.util.zip.DataFormatException;
import java.util.zip.Inflater; import java.util.zip.Inflater;
import org.checkerframework.checker.initialization.qual.UnknownInitialization; import org.checkerframework.checker.initialization.qual.UnknownInitialization;
import org.checkerframework.checker.nullness.compatqual.NullableType;
import org.checkerframework.checker.nullness.qual.EnsuresNonNull; import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
import org.checkerframework.checker.nullness.qual.PolyNull; import org.checkerframework.checker.nullness.qual.PolyNull;
...@@ -271,6 +272,13 @@ public final class Util { ...@@ -271,6 +272,13 @@ public final class Util {
return value; return value;
} }
/** Casts a nullable type array to a non-null type array without runtime null check. */
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull("#1")
public static <T> T[] castNonNullTypeArray(@NullableType T[] value) {
return value;
}
/** /**
* Copies and optionally truncates an array. Prevents null array elements created by {@link * Copies and optionally truncates an array. Prevents null array elements created by {@link
* Arrays#copyOf(Object[], int)} by ensuring the new length does not exceed the current length. * Arrays#copyOf(Object[], int)} by ensuring the new length does not exceed the current length.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment