Suppress go/nullness warnings caused by Matcher#group(String) and Matcher#group(int)
This is required to align google3's stub (currently marked non-null) with Checker Framework's. More information: go/matcher-nullness-lsc Tested: TAP train for global presubmit queue http://test/OCL:303344687:BASE:303326748:1585344475427:29edc250 PiperOrigin-RevId: 303709053
This commit is contained in:
parent
fd03949f85
commit
c7164a30a0
@ -818,6 +818,8 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
|
|||||||
Matcher matcher = CONTENT_RANGE_HEADER_PATTERN.matcher(contentRangeHeader);
|
Matcher matcher = CONTENT_RANGE_HEADER_PATTERN.matcher(contentRangeHeader);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
try {
|
try {
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
long contentLengthFromRange =
|
long contentLengthFromRange =
|
||||||
Long.parseLong(matcher.group(2)) - Long.parseLong(matcher.group(1)) + 1;
|
Long.parseLong(matcher.group(2)) - Long.parseLong(matcher.group(1)) + 1;
|
||||||
if (contentLength < 0) {
|
if (contentLength < 0) {
|
||||||
|
@ -1021,13 +1021,16 @@ public final class Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses an xs:dateTime attribute value, returning the parsed timestamp in milliseconds since
|
* Parses an xs:dateTime attribute value, returning the parsed timestamp in milliseconds since the
|
||||||
* the epoch.
|
* epoch.
|
||||||
*
|
*
|
||||||
* @param value The attribute value to decode.
|
* @param value The attribute value to decode.
|
||||||
* @return The parsed timestamp in milliseconds since the epoch.
|
* @return The parsed timestamp in milliseconds since the epoch.
|
||||||
* @throws ParserException if an error occurs parsing the dateTime attribute value.
|
* @throws ParserException if an error occurs parsing the dateTime attribute value.
|
||||||
*/
|
*/
|
||||||
|
// incompatible types in argument.
|
||||||
|
// dereference of possibly-null reference matcher.group(9)
|
||||||
|
@SuppressWarnings({"nullness:argument.type.incompatible", "nullness:dereference.of.nullable"})
|
||||||
public static long parseXsDateTime(String value) throws ParserException {
|
public static long parseXsDateTime(String value) throws ParserException {
|
||||||
Matcher matcher = XS_DATE_TIME_PATTERN.matcher(value);
|
Matcher matcher = XS_DATE_TIME_PATTERN.matcher(value);
|
||||||
if (!matcher.matches()) {
|
if (!matcher.matches()) {
|
||||||
@ -1719,6 +1722,8 @@ public final class Util {
|
|||||||
Matcher matcher = ESCAPED_CHARACTER_PATTERN.matcher(fileName);
|
Matcher matcher = ESCAPED_CHARACTER_PATTERN.matcher(fileName);
|
||||||
int startOfNotEscaped = 0;
|
int startOfNotEscaped = 0;
|
||||||
while (percentCharacterCount > 0 && matcher.find()) {
|
while (percentCharacterCount > 0 && matcher.find()) {
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
char unescapedCharacter = (char) Integer.parseInt(matcher.group(1), 16);
|
char unescapedCharacter = (char) Integer.parseInt(matcher.group(1), 16);
|
||||||
builder.append(fileName, startOfNotEscaped, matcher.start()).append(unescapedCharacter);
|
builder.append(fileName, startOfNotEscaped, matcher.start()).append(unescapedCharacter);
|
||||||
startOfNotEscaped = matcher.end();
|
startOfNotEscaped = matcher.end();
|
||||||
|
@ -44,6 +44,8 @@ public final class IcyDecoder implements MetadataDecoder {
|
|||||||
iso88591Decoder = Charset.forName(C.ISO88591_NAME).newDecoder();
|
iso88591Decoder = Charset.forName(C.ISO88591_NAME).newDecoder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// switching on a possibly-null value (key)
|
||||||
|
@SuppressWarnings("nullness:switching.nullable")
|
||||||
@Override
|
@Override
|
||||||
public Metadata decode(MetadataInputBuffer inputBuffer) {
|
public Metadata decode(MetadataInputBuffer inputBuffer) {
|
||||||
ByteBuffer buffer = Assertions.checkNotNull(inputBuffer.data);
|
ByteBuffer buffer = Assertions.checkNotNull(inputBuffer.data);
|
||||||
|
@ -229,6 +229,8 @@ import java.util.regex.Pattern;
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
String braceContents = matcher.group(1);
|
String braceContents = matcher.group(1);
|
||||||
try {
|
try {
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
PointF parsedPosition = parsePosition(braceContents);
|
PointF parsedPosition = parsePosition(braceContents);
|
||||||
if (parsedPosition != null) {
|
if (parsedPosition != null) {
|
||||||
position = parsedPosition;
|
position = parsedPosition;
|
||||||
@ -237,7 +239,10 @@ import java.util.regex.Pattern;
|
|||||||
// Ignore invalid \pos() or \move() function.
|
// Ignore invalid \pos() or \move() function.
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@SsaAlignment int parsedAlignment = parseAlignmentOverride(braceContents);
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
|
@SsaAlignment
|
||||||
|
int parsedAlignment = parseAlignmentOverride(braceContents);
|
||||||
if (parsedAlignment != SSA_ALIGNMENT_UNKNOWN) {
|
if (parsedAlignment != SSA_ALIGNMENT_UNKNOWN) {
|
||||||
alignment = parsedAlignment;
|
alignment = parsedAlignment;
|
||||||
}
|
}
|
||||||
@ -292,6 +297,8 @@ import java.util.regex.Pattern;
|
|||||||
Float.parseFloat(Assertions.checkNotNull(y).trim()));
|
Float.parseFloat(Assertions.checkNotNull(y).trim()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
@SsaAlignment
|
@SsaAlignment
|
||||||
private static int parseAlignmentOverride(String braceContents) {
|
private static int parseAlignmentOverride(String braceContents) {
|
||||||
Matcher matcher = ALIGNMENT_OVERRIDE_PATTERN.matcher(braceContents);
|
Matcher matcher = ALIGNMENT_OVERRIDE_PATTERN.matcher(braceContents);
|
||||||
|
@ -230,6 +230,8 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
|
|||||||
Cue.DIMEN_UNSET);
|
Cue.DIMEN_UNSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
private static long parseTimecode(Matcher matcher, int groupOffset) {
|
private static long parseTimecode(Matcher matcher, int groupOffset) {
|
||||||
@Nullable String hours = matcher.group(groupOffset + 1);
|
@Nullable String hours = matcher.group(groupOffset + 1);
|
||||||
long timestampMs = hours != null ? Long.parseLong(hours) * 60 * 60 * 1000 : 0;
|
long timestampMs = hours != null ? Long.parseLong(hours) * 60 * 60 * 1000 : 0;
|
||||||
|
@ -322,9 +322,11 @@ import java.util.regex.Pattern;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the target of a {@link WebvttCssStyle} by splitting a selector of the form
|
* Sets the target of a {@link WebvttCssStyle} by splitting a selector of the form {@code
|
||||||
* {@code ::cue(tag#id.class1.class2[voice="someone"]}, where every element is optional.
|
* ::cue(tag#id.class1.class2[voice="someone"]}, where every element is optional.
|
||||||
*/
|
*/
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
private void applySelectorToStyle(WebvttCssStyle style, String selector) {
|
private void applySelectorToStyle(WebvttCssStyle style, String selector) {
|
||||||
if ("".equals(selector)) {
|
if ("".equals(selector)) {
|
||||||
return; // Universal selector.
|
return; // Universal selector.
|
||||||
|
@ -322,6 +322,8 @@ public final class WebvttCueParser {
|
|||||||
|
|
||||||
// Internal methods
|
// Internal methods
|
||||||
|
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
@Nullable
|
@Nullable
|
||||||
private static WebvttCueInfo parseCue(
|
private static WebvttCueInfo parseCue(
|
||||||
@Nullable String id,
|
@Nullable String id,
|
||||||
@ -354,6 +356,8 @@ public final class WebvttCueParser {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
private static void parseCueSettingsList(String cueSettingsList, WebvttCueInfoBuilder builder) {
|
private static void parseCueSettingsList(String cueSettingsList, WebvttCueInfoBuilder builder) {
|
||||||
// Parse the cue settings list.
|
// Parse the cue settings list.
|
||||||
Matcher cueSettingMatcher = CUE_SETTING_PATTERN.matcher(cueSettingsList);
|
Matcher cueSettingMatcher = CUE_SETTING_PATTERN.matcher(cueSettingsList);
|
||||||
|
@ -113,6 +113,8 @@ import java.util.regex.Pattern;
|
|||||||
* @return The span, or null if the file name is not correctly formatted, or if the id is not
|
* @return The span, or null if the file name is not correctly formatted, or if the id is not
|
||||||
* present in the content index, or if the length is 0.
|
* present in the content index, or if the length is 0.
|
||||||
*/
|
*/
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
@Nullable
|
@Nullable
|
||||||
public static SimpleCacheSpan createCacheEntry(
|
public static SimpleCacheSpan createCacheEntry(
|
||||||
File file, long length, long lastTouchTimestamp, CachedContentIndex index) {
|
File file, long length, long lastTouchTimestamp, CachedContentIndex index) {
|
||||||
@ -131,6 +133,8 @@ import java.util.regex.Pattern;
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
int id = Integer.parseInt(matcher.group(1));
|
int id = Integer.parseInt(matcher.group(1));
|
||||||
@Nullable String key = index.getKeyForId(id);
|
@Nullable String key = index.getKeyForId(id);
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
@ -144,6 +148,8 @@ import java.util.regex.Pattern;
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
long position = Long.parseLong(matcher.group(2));
|
long position = Long.parseLong(matcher.group(2));
|
||||||
if (lastTouchTimestamp == C.TIME_UNSET) {
|
if (lastTouchTimestamp == C.TIME_UNSET) {
|
||||||
lastTouchTimestamp = Long.parseLong(matcher.group(3));
|
lastTouchTimestamp = Long.parseLong(matcher.group(3));
|
||||||
@ -159,6 +165,8 @@ import java.util.regex.Pattern;
|
|||||||
* @return Upgraded cache file or {@code null} if the file name is not correctly formatted or the
|
* @return Upgraded cache file or {@code null} if the file name is not correctly formatted or the
|
||||||
* file can not be renamed.
|
* file can not be renamed.
|
||||||
*/
|
*/
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
@Nullable
|
@Nullable
|
||||||
private static File upgradeFile(File file, CachedContentIndex index) {
|
private static File upgradeFile(File file, CachedContentIndex index) {
|
||||||
@Nullable String key = null;
|
@Nullable String key = null;
|
||||||
@ -177,6 +185,8 @@ import java.util.regex.Pattern;
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
File newCacheFile =
|
File newCacheFile =
|
||||||
getCacheFile(
|
getCacheFile(
|
||||||
Assertions.checkStateNotNull(file.getParentFile()),
|
Assertions.checkStateNotNull(file.getParentFile()),
|
||||||
|
@ -63,6 +63,8 @@ public final class ColorParser {
|
|||||||
return parseColorInternal(colorExpression, true);
|
return parseColorInternal(colorExpression, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
private static int parseColorInternal(String colorExpression, boolean alphaHasFloatFormat) {
|
private static int parseColorInternal(String colorExpression, boolean alphaHasFloatFormat) {
|
||||||
Assertions.checkArgument(!TextUtils.isEmpty(colorExpression));
|
Assertions.checkArgument(!TextUtils.isEmpty(colorExpression));
|
||||||
colorExpression = colorExpression.replace(" ", "");
|
colorExpression = colorExpression.replace(" ", "");
|
||||||
|
@ -133,6 +133,8 @@ public final class WebvttExtractor implements Extractor {
|
|||||||
return Extractor.RESULT_END_OF_INPUT;
|
return Extractor.RESULT_END_OF_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
@RequiresNonNull("output")
|
@RequiresNonNull("output")
|
||||||
private void processSample() throws ParserException {
|
private void processSample() throws ParserException {
|
||||||
ParsableByteArray webvttData = new ParsableByteArray(sampleData);
|
ParsableByteArray webvttData = new ParsableByteArray(sampleData);
|
||||||
@ -170,6 +172,8 @@ public final class WebvttExtractor implements Extractor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
long firstCueTimeUs = WebvttParserUtil.parseTimestampUs(cueHeaderMatcher.group(1));
|
long firstCueTimeUs = WebvttParserUtil.parseTimestampUs(cueHeaderMatcher.group(1));
|
||||||
long sampleTimeUs = timestampAdjuster.adjustTsTimestamp(
|
long sampleTimeUs = timestampAdjuster.adjustTsTimestamp(
|
||||||
TimestampAdjuster.usToPts(firstCueTimeUs + tsTimestampUs - vttTimestampUs));
|
TimestampAdjuster.usToPts(firstCueTimeUs + tsTimestampUs - vttTimestampUs));
|
||||||
|
@ -823,6 +823,8 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
|||||||
return Integer.parseInt(parseStringAttr(line, pattern, Collections.emptyMap()));
|
return Integer.parseInt(parseStringAttr(line, pattern, Collections.emptyMap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incompatible types in argument.
|
||||||
|
@SuppressWarnings("nullness:argument.type.incompatible")
|
||||||
private static int parseOptionalIntAttr(String line, Pattern pattern, int defaultValue) {
|
private static int parseOptionalIntAttr(String line, Pattern pattern, int defaultValue) {
|
||||||
Matcher matcher = pattern.matcher(line);
|
Matcher matcher = pattern.matcher(line);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
@ -855,6 +857,8 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
|||||||
return parseOptionalStringAttr(line, pattern, null, variableDefinitions);
|
return parseOptionalStringAttr(line, pattern, null, variableDefinitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// incompatible types in return.
|
||||||
|
@SuppressWarnings("nullness:return.type.incompatible")
|
||||||
private static @PolyNull String parseOptionalStringAttr(
|
private static @PolyNull String parseOptionalStringAttr(
|
||||||
String line,
|
String line,
|
||||||
Pattern pattern,
|
Pattern pattern,
|
||||||
@ -885,6 +889,8 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
|||||||
return stringWithReplacements.toString();
|
return stringWithReplacements.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dereference of possibly-null reference matcher.group(1)
|
||||||
|
@SuppressWarnings("nullness:dereference.of.nullable")
|
||||||
private static boolean parseOptionalBooleanAttribute(
|
private static boolean parseOptionalBooleanAttribute(
|
||||||
String line, Pattern pattern, boolean defaultValue) {
|
String line, Pattern pattern, boolean defaultValue) {
|
||||||
Matcher matcher = pattern.matcher(line);
|
Matcher matcher = pattern.matcher(line);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user