Commit 77715fbf by andrewlewis Committed by Oliver Woodman

Fix some analysis warnings.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=139901449
parent e84fa583
...@@ -48,5 +48,5 @@ dependencies { ...@@ -48,5 +48,5 @@ dependencies {
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2' androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile 'org.mockito:mockito-core:1.9.5' androidTestCompile 'org.mockito:mockito-core:1.9.5'
androidTestCompile project(':library') androidTestCompile project(':library')
androidTestCompile 'com.android.support.test:runner:0.4' androidTestCompile 'com.android.support.test:runner:0.5'
} }
...@@ -57,7 +57,7 @@ dependencies { ...@@ -57,7 +57,7 @@ dependencies {
androidTestCompile 'com.google.dexmaker:dexmaker:1.2' androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2' androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile 'org.mockito:mockito-core:1.9.5' androidTestCompile 'org.mockito:mockito-core:1.9.5'
compile 'com.android.support:support-annotations:24.2.1' compile 'com.android.support:support-annotations:25.0.1'
} }
android.libraryVariants.all { variant -> android.libraryVariants.all { variant ->
......
...@@ -110,8 +110,8 @@ public final class DefaultOggSeekerTest extends TestCase { ...@@ -110,8 +110,8 @@ public final class DefaultOggSeekerTest extends TestCase {
long granuleDiff = currentGranule - targetGranule; long granuleDiff = currentGranule - targetGranule;
if ((granuleDiff > DefaultOggSeeker.MATCH_RANGE || granuleDiff < 0) if ((granuleDiff > DefaultOggSeeker.MATCH_RANGE || granuleDiff < 0)
&& positionDiff > DefaultOggSeeker.MATCH_BYTE_RANGE) { && positionDiff > DefaultOggSeeker.MATCH_BYTE_RANGE) {
fail(String.format("granuleDiff (%d) or positionDiff (%d) is more than allowed.", fail("granuleDiff (" + granuleDiff + ") or positionDiff (" + positionDiff
granuleDiff, positionDiff)); + ") is more than allowed.");
} }
} }
} }
......
...@@ -28,7 +28,7 @@ import junit.framework.TestCase; ...@@ -28,7 +28,7 @@ import junit.framework.TestCase;
*/ */
public class DefaultOggSeekerUtilMethodsTest extends TestCase { public class DefaultOggSeekerUtilMethodsTest extends TestCase {
private Random random = new Random(0); private final Random random = new Random(0);
public void testSkipToNextPage() throws Exception { public void testSkipToNextPage() throws Exception {
FakeExtractorInput extractorInput = TestData.createInput( FakeExtractorInput extractorInput = TestData.createInput(
......
...@@ -25,16 +25,16 @@ import junit.framework.Assert; ...@@ -25,16 +25,16 @@ import junit.framework.Assert;
*/ */
/* package */ final class OggTestFile { /* package */ final class OggTestFile {
public static final int MAX_PACKET_LENGTH = 2048; private static final int MAX_PACKET_LENGTH = 2048;
public static final int MAX_SEGMENT_COUNT = 10; private static final int MAX_SEGMENT_COUNT = 10;
public static final int MAX_GRANULES_IN_PAGE = 100000; private static final int MAX_GRANULES_IN_PAGE = 100000;
byte[] data; public final byte[] data;
long lastGranule; public final long lastGranule;
int packetCount; public final int packetCount;
int pageCount; public final int pageCount;
int firstPayloadPageSize; public final int firstPayloadPageSize;
long firstPayloadPageGranulePosition; public final long firstPayloadPageGranulePosition;
private OggTestFile(byte[] data, long lastGranule, int packetCount, int pageCount, private OggTestFile(byte[] data, long lastGranule, int packetCount, int pageCount,
int firstPayloadPageSize, long firstPayloadPageGranulePosition) { int firstPayloadPageSize, long firstPayloadPageGranulePosition) {
......
...@@ -31,7 +31,6 @@ import com.google.android.exoplayer2.testutil.FakeTrackOutput; ...@@ -31,7 +31,6 @@ import com.google.android.exoplayer2.testutil.FakeTrackOutput;
import com.google.android.exoplayer2.testutil.TestUtil; import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Random; import java.util.Random;
/** /**
...@@ -114,7 +113,7 @@ public final class TsExtractorTest extends InstrumentationTestCase { ...@@ -114,7 +113,7 @@ public final class TsExtractorTest extends InstrumentationTestCase {
assertEquals(1, factory.sdtReader.consumedSdts); assertEquals(1, factory.sdtReader.consumedSdts);
} }
private static void writeJunkData(ByteArrayOutputStream out, int length) throws IOException { private static void writeJunkData(ByteArrayOutputStream out, int length) {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
if (((byte) i) == TS_SYNC_BYTE) { if (((byte) i) == TS_SYNC_BYTE) {
out.write(0); out.write(0);
......
...@@ -97,7 +97,7 @@ public final class Mp4WebvttDecoderTest extends TestCase { ...@@ -97,7 +97,7 @@ public final class Mp4WebvttDecoderTest extends TestCase {
public void testNoCueSample() throws SubtitleDecoderException { public void testNoCueSample() throws SubtitleDecoderException {
Mp4WebvttDecoder decoder = new Mp4WebvttDecoder(); Mp4WebvttDecoder decoder = new Mp4WebvttDecoder();
Subtitle result = decoder.decode(NO_CUE_SAMPLE, NO_CUE_SAMPLE.length); Subtitle result = decoder.decode(NO_CUE_SAMPLE, NO_CUE_SAMPLE.length);
assertMp4WebvttSubtitleEquals(result, new Cue[0]); assertMp4WebvttSubtitleEquals(result);
} }
// Negative tests. // Negative tests.
......
...@@ -28,7 +28,7 @@ public class CachedContentIndexTest extends InstrumentationTestCase { ...@@ -28,7 +28,7 @@ public class CachedContentIndexTest extends InstrumentationTestCase {
0, 0, 0, 0, 0, 0, 0, 10, // original_content_length 0, 0, 0, 0, 0, 0, 0, 10, // original_content_length
0, 0, 0, 2, // cache_id 0, 0, 0, 2, // cache_id
0, 5, 75, 76, 77, 78, 79, // cache_key 0, 5, 75, 76, 77, 78, 79, // cache_key
0, 0, 0, 0, 0, 0, 10, 00, // original_content_length 0, 0, 0, 0, 0, 0, 10, 0, // original_content_length
(byte) 0xF6, (byte) 0xFB, 0x50, 0x41 // hashcode_of_CachedContent_array (byte) 0xF6, (byte) 0xFB, 0x50, 0x41 // hashcode_of_CachedContent_array
}; };
private CachedContentIndex index; private CachedContentIndex index;
......
...@@ -69,10 +69,12 @@ public class AtomicFileTest extends InstrumentationTestCase { ...@@ -69,10 +69,12 @@ public class AtomicFileTest extends InstrumentationTestCase {
output.write(6); output.write(6);
assertRead(); assertRead();
output.close();
output = atomicFile.startWrite(); output = atomicFile.startWrite();
assertRead(); assertRead();
output.close();
} }
private void assertRead() throws IOException { private void assertRead() throws IOException {
......
...@@ -447,15 +447,15 @@ public class StreamingDrmSessionManager<T extends ExoMediaCrypto> implements Drm ...@@ -447,15 +447,15 @@ public class StreamingDrmSessionManager<T extends ExoMediaCrypto> implements Drm
switch (msg.what) { switch (msg.what) {
case MediaDrm.EVENT_KEY_REQUIRED: case MediaDrm.EVENT_KEY_REQUIRED:
postKeyRequest(); postKeyRequest();
return; break;
case MediaDrm.EVENT_KEY_EXPIRED: case MediaDrm.EVENT_KEY_EXPIRED:
state = STATE_OPENED; state = STATE_OPENED;
onError(new KeysExpiredException()); onError(new KeysExpiredException());
return; break;
case MediaDrm.EVENT_PROVISION_REQUIRED: case MediaDrm.EVENT_PROVISION_REQUIRED:
state = STATE_OPENED; state = STATE_OPENED;
postProvisionRequest(); postProvisionRequest();
return; break;
} }
} }
...@@ -483,10 +483,10 @@ public class StreamingDrmSessionManager<T extends ExoMediaCrypto> implements Drm ...@@ -483,10 +483,10 @@ public class StreamingDrmSessionManager<T extends ExoMediaCrypto> implements Drm
switch (msg.what) { switch (msg.what) {
case MSG_PROVISION: case MSG_PROVISION:
onProvisionResponse(msg.obj); onProvisionResponse(msg.obj);
return; break;
case MSG_KEYS: case MSG_KEYS:
onKeyResponse(msg.obj); onKeyResponse(msg.obj);
return; break;
} }
} }
......
...@@ -369,22 +369,22 @@ public final class Cea608Decoder extends CeaDecoder { ...@@ -369,22 +369,22 @@ public final class Cea608Decoder extends CeaDecoder {
if (captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_PAINT_ON) { if (captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_PAINT_ON) {
captionStringBuilder.setLength(0); captionStringBuilder.setLength(0);
} }
return; break;
case CTRL_ERASE_NON_DISPLAYED_MEMORY: case CTRL_ERASE_NON_DISPLAYED_MEMORY:
captionStringBuilder.setLength(0); captionStringBuilder.setLength(0);
return; break;
case CTRL_END_OF_CAPTION: case CTRL_END_OF_CAPTION:
captionString = getDisplayCaption(); captionString = getDisplayCaption();
captionStringBuilder.setLength(0); captionStringBuilder.setLength(0);
return; break;
case CTRL_CARRIAGE_RETURN: case CTRL_CARRIAGE_RETURN:
maybeAppendNewline(); maybeAppendNewline();
return; break;
case CTRL_BACKSPACE: case CTRL_BACKSPACE:
if (captionStringBuilder.length() > 0) { if (captionStringBuilder.length() > 0) {
captionStringBuilder.setLength(captionStringBuilder.length() - 1); captionStringBuilder.setLength(captionStringBuilder.length() - 1);
} }
return; break;
} }
} }
......
...@@ -113,8 +113,8 @@ public final class ParsingLoadable<T> implements Loadable { ...@@ -113,8 +113,8 @@ public final class ParsingLoadable<T> implements Loadable {
inputStream.open(); inputStream.open();
result = parser.parse(dataSource.getUri(), inputStream); result = parser.parse(dataSource.getUri(), inputStream);
} finally { } finally {
inputStream.close();
bytesLoaded = inputStream.bytesRead(); bytesLoaded = inputStream.bytesRead();
inputStream.close();
} }
} }
......
...@@ -354,10 +354,7 @@ public final class SimpleCache implements Cache { ...@@ -354,10 +354,7 @@ public final class SimpleCache implements Cache {
@Override @Override
public synchronized boolean isCached(String key, long position, long length) { public synchronized boolean isCached(String key, long position, long length) {
CachedContent cachedContent = index.get(key); CachedContent cachedContent = index.get(key);
if (cachedContent == null) { return cachedContent != null && cachedContent.isCached(position, length);
return false;
}
return cachedContent.isCached(position, length);
} }
@Override @Override
......
...@@ -98,7 +98,7 @@ public final class AtomicFile { ...@@ -98,7 +98,7 @@ public final class AtomicFile {
baseName.delete(); baseName.delete();
} }
} }
OutputStream str = null; OutputStream str;
try { try {
str = new AtomicFileOutputStream(baseName); str = new AtomicFileOutputStream(baseName);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
......
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